From: <Salvato da Windows Internet Explorer 7>
Subject: Risolutore javascript di equazioni di quarto grado
Date: Fri, 12 Sep 2008 18:29:40 +0200
MIME-Version: 1.0
Content-Type: multipart/related;
	type="text/html";
	boundary="----=_NextPart_000_0008_01C91505.84A0F2D0"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579

This is a multi-part message in MIME format.

------=_NextPart_000_0008_01C91505.84A0F2D0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://utenti.quipo.it/base5/numeri/equasolutore4.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" =
"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML><HEAD><TITLE>Risolutore javascript di equazioni di quarto =
grado</TITLE>
<META http-equiv=3Dcontent-type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"Gianfranco Bo" name=3DAuthor>
<META content=3D"MSHTML 6.00.6000.16705" name=3DGENERATOR>
<META content=3DFrontPage.Editor.Document name=3DProgId><LINK=20
href=3D"http://utenti.quipo.it/base5/stileb5.css" type=3Dtext/css =
rel=3Dstylesheet>
<SCRIPT language=3Djavascript type=3Dtext/javascript>
<!-- hide
//---------------------------// quartic root code
//---------------------------
var fzero =3D parseFloat( "0.0" );
var izero =3D parseInt( "0" );
var coeff =3D new Array( fzero, fzero, fzero, fzero );
var real  =3D new Array( fzero, fzero, fzero, fzero );
var imag  =3D new Array( fzero, fzero, fzero, fzero );

//
// first coefficient is always =3D 1
//

function calculate()
{
document.calc.re_1.value =3D "Non riesco a risolverlo";
document.calc.im_1.value =3D 0;
document.calc.re_2.value =3D 0;
document.calc.im_2.value =3D 0;
document.calc.re_3.value =3D 0;
document.calc.im_3.value =3D 0;
document.calc.re_4.value =3D 0;
document.calc.im_4.value =3D 0;

coeff[0] =3D parseFloat( document.calc.coeff_d.value );
coeff[1] =3D parseFloat( document.calc.coeff_c.value );
coeff[2] =3D parseFloat( document.calc.coeff_b.value );
coeff[3] =3D parseFloat( document.calc.coeff_a.value );
coeff[4] =3D parseFloat( document.calc.coeff_a0.value );

var TOLERANCE =3D parseFloat( "0.00000001" );
var LIMIT =3D parseInt( "50" );
var beta1  =3D fzero;
var beta2  =3D fzero;
var delta1 =3D fzero;
var delta2 =3D fzero;
var delta3 =3D fzero;

var i =3D izero;
var j =3D izero;
var k =3D izero;

var n  =3D parseInt( "4" );       // order
var n1 =3D parseInt( "5" );
var n2 =3D parseInt( "6" );

var a =3D new Array( fzero, fzero, fzero, fzero );
var b =3D new Array( fzero, fzero, fzero, fzero );
var c =3D new Array( fzero, fzero, fzero, fzero );
var d =3D new Array( fzero, fzero, fzero, fzero );

if (coeff[4] =3D=3D 0)
return;

if (coeff[4] /=3D 1)
{
coeff[0] =3D coeff[0]/coeff[4];
coeff[1] =3D coeff[1]/coeff[4];
coeff[2] =3D coeff[2]/coeff[4];
coeff[3] =3D coeff[3]/coeff[4];
coeff[4] =3D 1;
}

// is the coefficient of the highest term zero?
if( Math.abs( coeff[0] ) < TOLERANCE )
return;

for( i =3D 0; i <=3D n; i++ )      //  copy into working array
a[n1-i] =3D coeff[i];

var count =3D izero;             // initialize root counter

// start the main Lin-Bairstow iteration loop
do
{
// initialize the counter and guesses for the
// coefficients of quadratic factor:
//
// p(x) =3D x^2 + alfa1*x + beta1
var alfa1 =3D Math.random() - 0.5;
var beta1 =3D Math.random() - 0.5;
var limit =3D parseInt( "1000" );

do
{
b[0] =3D 0;
d[0] =3D 0;
b[1] =3D 1;
d[1] =3D 1;

j =3D 1;
k =3D 0;

for( i =3D 2; i <=3D n1; i++ )
{
b[i] =3D a[i] - alfa1 * b[j] - beta1 * b[k];
d[i] =3D b[i] - alfa1 * d[j] - beta1 * d[k];
j =3D j + 1;
k =3D k + 1;
}

j =3D n - 1;
k =3D n - 2;
delta1 =3D d[j] * d[j] - ( d[n] - b[n] ) * d[k];
alfa2 =3D ( b[n] * d[j] - b[n1] * d[k] ) / delta1;
beta2 =3D ( b[n1] * d[j] - ( d[n] - b[n] ) * b[n] ) / delta1;
alfa1 =3D alfa1 + alfa2;
beta1 =3D beta1 + beta2;

if( --limit < 0 )         // cannot solve
return;

if( Math.abs( alfa2 ) < TOLERANCE && Math.abs( beta2 ) < TOLERANCE )
break;
}
while( true );

delta1 =3D alfa1*alfa1 - 4 * beta1;

if( delta1 < 0 )              // imaginary roots
{
delta2 =3D Math.sqrt( Math.abs( delta1 ) ) / 2;
delta3 =3D -alfa1 / 2;

real[count]   =3D  delta3;
imag[count]   =3D  delta2;

real[count+1] =3D  delta3;
imag[count+1] =3D  delta2;  // sign is inverted on display
}
else                          // roots are real
{
delta2 =3D Math.sqrt( delta1 );

real[count]   =3D ( delta2 - alfa1 ) / 2;
imag[count]   =3D 0;

real[count+1] =3D ( delta2 + alfa1 ) / ( -2 );
imag[count+1] =3D 0;
}


count =3D count + 2;            // update root counter

n  =3D n  - 2;                  // reduce polynomial order
n1 =3D n1 - 2;
n2 =3D n2 - 2;

// for n >=3D 2 calculate coefficients of
//  the new polynomial
if( n >=3D 2 )
{
for( i =3D 1; i <=3D n1; i++ )
a[i] =3D b[i];
}

if( n < 2 ) break;
}
while( true );

if( n =3D=3D 1 )
{
// obtain last single real root
real[count] =3D -b[2];
imag[count] =3D 0;
}

if( document.calc.group1[0].checked ) // round results
{
document.calc.re_1.value =3D Math.round( 100000.0*real[0] ) / 100000.0;
document.calc.im_1.value =3D Math.round( 100000.0*imag[0] ) / 100000.0;
document.calc.re_2.value =3D Math.round( 100000.0*real[1] ) / 100000.0;
document.calc.im_2.value =3D Math.round( 100000.0*imag[1] ) / 100000.0;
document.calc.re_3.value =3D Math.round( 100000.0*real[2] ) / 100000.0;
document.calc.im_3.value =3D Math.round( 100000.0*imag[2] ) / 100000.0;
document.calc.re_4.value =3D Math.round( 100000.0*real[3] ) / 100000.0;
document.calc.im_4.value =3D Math.round( 100000.0*imag[3] ) / 100000.0;
}
else
{
document.calc.re_1.value =3D real[0];
document.calc.im_1.value =3D imag[0];
document.calc.re_2.value =3D real[1];
document.calc.im_2.value =3D imag[1];
document.calc.re_3.value =3D real[2];
document.calc.im_3.value =3D imag[2];
document.calc.re_4.value =3D real[3];
document.calc.im_4.value =3D imag[3];
}
}

function allclear()
{
document.calc.coeff_a0.value=3D'0';
document.calc.coeff_a.value=3D'0';
document.calc.coeff_b.value=3D'0';
document.calc.coeff_c.value=3D'0';
document.calc.coeff_d.value=3D'0';
}
// unhide -->
  </SCRIPT>
</HEAD>
<BODY>
<P>[<A href=3D"http://utenti.quipo.it/base5/index.htm"><B>HOME - BASE =
Cinque</B> -=20
<I>Appunti di Matematica ricreativa</I></A>]</P>
<H1 align=3Dcenter>Risolutore di equazioni di 4=B0 grado</H1>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"100%" align=3Dcenter =
border=3D0>
  <TBODY>
  <TR>
    <TD><FONT color=3D#ff0000 size=3D4><B>Equazioni di 4=B0 =
grado</B></FONT>=20
      <P>Un'equazione di 4=B0 grado =E8 della forma:<BR><B>a</B> x =
<SUP>4</SUP> +=20
      <B>b</B> x <SUP>3</SUP> + <B>c</B> x <SUP>2</SUP> + <B>d</B> x + =
<B>e</B>=20
      =3D 0<BR>dove a, b, c, d, e, sono i coefficienti e x =E8 =
l'incognita.<BR>Le=20
      equazioni di quarto grado hanno quattro soluzioni.<BR>Inserite i =
valori=20
      numerici dei coefficienti a, b, c, d, e, nel quadro qui sotto e =
cliccate=20
      su "Risolvi!"<BR><B>Note:<BR>1) se un coefficiente =E8 nullo, =
bisogna=20
      inserire il numero "0";<BR></B>2) il programma usa l'algoritmo =
iterativo=20
      di <B>Lin-Bairstow</B> che parte con un insieme di valori generati =
a caso.=20
      Perci=F2, facendo risolvere pi=F9 volte una stessa equazione, si =
possono=20
      ottenere permutazioni diverse delle radici;<BR>3) se a =3D 0 =
oppure e=3D0 si=20
      ottiene il messaggio "<B>Non riesco a risolverlo</B>"; in questi =
casi=20
      l'equazione =E8 di 3=B0 grado o =E8 riducibile al 3=B0 grado; =
potete quindi usare=20
      il Risolutore di equazioni di 2=B0 e 3=B0 grado.</P>
      <FORM name=3Dcalc>
      <BLOCKQUOTE>
        <P>a: <INPUT maxLength=3D30 size=3D10 value=3D0 name=3Dcoeff_a0> =
b: <INPUT=20
        maxLength=3D30 size=3D10 value=3D0 name=3Dcoeff_a> c: <INPUT =
maxLength=3D30=20
        size=3D10 value=3D0 name=3Dcoeff_b> d: <INPUT maxLength=3D30 =
size=3D10 value=3D0=20
        name=3Dcoeff_c> e: <INPUT maxLength=3D30 size=3D10 value=3D0 =
name=3Dcoeff_d></P>
        <P><INPUT type=3Dradio CHECKED value=3Drnd name=3Dgroup1> =
Approssima a 5 cifre=20
        decimali<BR><INPUT type=3Dradio value=3Dnor name=3Dgroup1> Usa =
tutte le cifre=20
        possibili</P>
        <P><INPUT onclick=3Dcalculate() type=3Dbutton =
value=3DRisolvi!></P>
        <P>x1 =3D <INPUT maxLength=3D30 value=3D0 name=3Dre_1> + <INPUT =
maxLength=3D30=20
        value=3D0 name=3Dim_1>i</P>
        <P>x2 =3D <INPUT maxLength=3D30 value=3D0 name=3Dre_2> - <INPUT =
maxLength=3D30=20
        value=3D0 name=3Dim_2>i</P>
        <P>x3 =3D <INPUT maxLength=3D30 value=3D0 name=3Dre_3> + <INPUT =
maxLength=3D30=20
        value=3D0 name=3Dim_3>i</P>
        <P>x4 =3D <INPUT maxLength=3D30 value=3D0 name=3Dre_4> - <INPUT =
maxLength=3D30=20
        value=3D0 name=3Dim_4>i</P>
        <P><INPUT onclick=3Dallclear() type=3Dbutton =
value=3DCancella></P></BLOCKQUOTE></FORM></TD></TR></TBODY></TABLE>
<P align=3Dleft>Equazione di 4=B0 grado: <B>a</B> x <SUP>4</SUP> + =
<B>b</B> x=20
<SUP>3</SUP> + <B>c</B> x <SUP>2</SUP> + <B>d</B> x + <B>e</B> =3D =
0<BR>Se vi=20
interessa la formula risolutiva per radicali, vi rimando a questo link: =
<A=20
href=3D"http://planetmath.org/encyclopedia/QuarticFormula.html">http://pl=
anetmath.org/encyclopedia/QuarticFormula.html</A></P>
<P align=3Dleft>Ho completamente cambiato l'algoritmo di questo =
risolutore in=20
seguito ad un messaggio di <B>Attilio Scifoni</B> che segnalava errori =
nel=20
programma precedente. Ringrazio di cuore e spero che questo programma =
funzioni=20
meglio.<BR>Il programma originale di <B>Stephen R. Schmitt</B> assegnava =

obbligatoriamente <I>a</I> =3D 1. Io mi sono limitato ad apportare una =
piccola=20
variante permettendo di inserire qualunque valore per <I>a</I>, escluso =
lo 0=20
(zero).</P>
<HR>

<H1 style=3D"TEXT-ALIGN: center">Risposte &amp; riflessioni</H1>
<P align=3Dleft>&nbsp;</P>
<P align=3Dleft><I>Documento creato il: novembre 2007<BR>Ultimo =
aggiornamento:=20
novembre 2007</I></P>
<HR>

<P style=3D"TEXT-ALIGN: center">Sito Web realizzato da <B>Gianfranco=20
Bo</B></P></BODY></HTML>

------=_NextPart_000_0008_01C91505.84A0F2D0
Content-Type: text/css;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://utenti.quipo.it/base5/stileb5.css

BODY {
	FONT-WEIGHT: normal; BACKGROUND: white; MARGIN-LEFT: 4em; COLOR: black; =
MARGIN-RIGHT: 8em; FONT-STYLE: normal; FONT-FAMILY: Helvetica, Arial, =
sans-serif; TEXT-ALIGN: left
}
P {
	PADDING-RIGHT: 0em; MARGIN-TOP: 0.3em; PADDING-LEFT: 0em; =
MARGIN-BOTTOM: 0.3em; PADDING-BOTTOM: 0em; TEXT-INDENT: 0em; =
PADDING-TOP: 0em; TEXT-ALIGN: left
}
H1 {
	COLOR: #9f1d35
}
H2 {
	COLOR: #9f1d35
}
H3 {
	COLOR: #9f1d35
}
H4 {
	COLOR: #9f1d35
}
H5 {
	COLOR: #9f1d35
}
H1 {
	PADDING-RIGHT: 0em; MARGIN-TOP: 1.33em; PADDING-LEFT: 0em; FONT-WEIGHT: =
bold; FONT-SIZE: 2em; MARGIN-BOTTOM: 0.33em; PADDING-BOTTOM: 0em; =
PADDING-TOP: 0em; FONT-STYLE: normal
}
H2 {
	PADDING-RIGHT: 0em; MARGIN-TOP: 1.75em; PADDING-LEFT: 0em; FONT-WEIGHT: =
normal; FONT-SIZE: 1.75em; MARGIN-BOTTOM: 0.33em; PADDING-BOTTOM: 0em; =
PADDING-TOP: 0em; FONT-STYLE: normal; TEXT-ALIGN: left
}
H3 {
	PADDING-RIGHT: 0em; MARGIN-TOP: 1.58em; PADDING-LEFT: 0em; FONT-WEIGHT: =
bold; FONT-SIZE: 1.58em; MARGIN-BOTTOM: 0.33em; PADDING-BOTTOM: 0em; =
PADDING-TOP: 0em; FONT-STYLE: normal; TEXT-ALIGN: left
}
H4 {
	PADDING-RIGHT: 0em; MARGIN-TOP: 1.33em; PADDING-LEFT: 0em; FONT-WEIGHT: =
bold; FONT-SIZE: 1.33em; MARGIN-BOTTOM: 0.33em; PADDING-BOTTOM: 0em; =
PADDING-TOP: 0em; FONT-STYLE: normal; TEXT-ALIGN: left
}
H5 {
	PADDING-RIGHT: 0em; MARGIN-TOP: 1.17em; PADDING-LEFT: 0em; FONT-WEIGHT: =
bold; FONT-SIZE: 1.17em; MARGIN-BOTTOM: 0.33em; PADDING-BOTTOM: 0em; =
PADDING-TOP: 0em; FONT-STYLE: italic; TEXT-ALIGN: left
}
DIV {
	PADDING-RIGHT: 0em; MARGIN-TOP: 0em; PADDING-LEFT: 0em; MARGIN-BOTTOM: =
0em; PADDING-BOTTOM: 0em; PADDING-TOP: 0em
}
BLOCKQUOTE {
	PADDING-RIGHT: 0em; PADDING-LEFT: 0em; PADDING-BOTTOM: 0em; MARGIN: =
0.5em 1em; PADDING-TOP: 0em; FONT-STYLE: italic
}
CITE {
	PADDING-RIGHT: 0em; PADDING-LEFT: 0em; PADDING-BOTTOM: 0em; MARGIN: =
0em; PADDING-TOP: 0em; FONT-STYLE: italic; FONT-FAMILY: Helvetica, =
Arial, sans-serif
}
TABLE {
	BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; =
BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; =
BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #ffffcc
}
TABLE TH {
	BORDER-RIGHT: #808080 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: =
#808080 1px solid; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; BORDER-LEFT: =
#808080 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #808080 1px solid
}
TABLE TD {
	BORDER-RIGHT: #808080 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: =
#808080 1px solid; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; BORDER-LEFT: =
#808080 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #808080 1px solid
}
UL {
	PADDING-RIGHT: 0em; MARGIN-TOP: 0.5em; PADDING-LEFT: 0em; =
MARGIN-BOTTOM: 0.5em; PADDING-BOTTOM: 0em; MARGIN-LEFT: 0em; =
PADDING-TOP: 0em
}
OL {
	PADDING-RIGHT: 0em; MARGIN-TOP: 0.5em; PADDING-LEFT: 0em; =
MARGIN-BOTTOM: 0.5em; PADDING-BOTTOM: 0em; MARGIN-LEFT: 0em; =
PADDING-TOP: 0em
}
LI {
	PADDING-RIGHT: 0em; MARGIN-TOP: 0.5em; PADDING-LEFT: 0em; =
MARGIN-BOTTOM: 0.5em; PADDING-BOTTOM: 0em; MARGIN-LEFT: 1.5em; =
PADDING-TOP: 0em; TEXT-ALIGN: left
}
DL {
	PADDING-RIGHT: 0em; MARGIN-TOP: 0.5em; PADDING-LEFT: 0em; =
MARGIN-BOTTOM: 0.5em; PADDING-BOTTOM: 0em; MARGIN-LEFT: 0em; =
PADDING-TOP: 0em
}
DT {
	PADDING-RIGHT: 0em; MARGIN-TOP: 0.3em; PADDING-LEFT: 0em; FONT-WEIGHT: =
bold; MARGIN-BOTTOM: 0.3em; PADDING-BOTTOM: 0em; PADDING-TOP: 0em
}
DD {
	PADDING-RIGHT: 0em; MARGIN-TOP: 0.3em; PADDING-LEFT: 0em; =
MARGIN-BOTTOM: 0.3em; PADDING-BOTTOM: 0em; MARGIN-LEFT: 0.5em; =
PADDING-TOP: 0em
}
DL {
	MARGIN-TOP: 0.3em; MARGIN-BOTTOM: 0.3em
}
STRONG {
	FONT-WEIGHT: bold
}
EM {
	FONT-STYLE: italic
}
CODE {
	FONT-FAMILY: Courier New, Courier, monospace
}
INS {
	BACKGROUND-COLOR: yellow; TEXT-DECORATION: underline
}
DEL {
	TEXT-DECORATION: line-through
}
A[href] {
	COLOR: blue; TEXT-DECORATION: underline
}
HR {
	COLOR: #999999; HEIGHT: 1px
}

------=_NextPart_000_0008_01C91505.84A0F2D0--

