Professional Documents
Culture Documents
<head>
<title>quartic root calculator</title>
<link rel="stylesheet" type="text/css" href="../standard.css">
<SCRIPT language=JavaScript SRC="../feedback.js"></SCRIPT>
<script language=JavaScript>
<!-- hide
//--------------------------// quartic root code
//--------------------------var
var
var
var
var
fzero
izero
coeff
real
imag
=
=
=
=
=
parseFloat( "0.0"
parseInt( "0" );
new Array( fzero,
new Array( fzero,
new Array( fzero,
);
fzero, fzero, fzero );
fzero, fzero, fzero );
fzero, fzero, fzero );
//
// first coefficient is always = 1
//
function calculate()
{
document.calc.re_1.value
document.calc.im_1.value
document.calc.re_2.value
document.calc.im_2.value
document.calc.re_3.value
document.calc.im_3.value
document.calc.re_4.value
document.calc.im_4.value
coeff[0]
coeff[1]
coeff[2]
coeff[3]
coeff[4]
var
var
var
var
var
var
var
=
=
=
=
=
parseFloat(
parseFloat(
parseFloat(
parseFloat(
parseFloat(
=
=
=
=
=
=
=
=
"cannot solve";
0;
0;
0;
0;
0;
0;
0;
document.calc.coeff_d.value
document.calc.coeff_c.value
document.calc.coeff_b.value
document.calc.coeff_a.value
"1.0" );
var i = izero;
var j = izero;
var k = izero;
var n = parseInt( "4" );
var n1 = parseInt( "5" );
var n2 = parseInt( "6" );
var
var
var
var
a
b
c
d
=
=
=
=
new
new
new
new
Array(
Array(
Array(
Array(
fzero,
fzero,
fzero,
fzero,
// order
fzero,
fzero,
fzero,
fzero,
fzero,
fzero,
fzero,
fzero,
fzero
fzero
fzero
fzero
);
);
);
);
);
);
);
);
=
=
=
=
0;
0;
1;
1;
j = 1;
k = 0;
for( i = 2; i <= n1; i++ )
{
b[i] = a[i] - alfa1 * b[j] - beta1 * b[k];
d[i] = b[i] - alfa1 * d[j] - beta1 * d[k];
j = j + 1;
k = k + 1;
}
j = n - 1;
k = n - 2;
delta1 = d[j] * d[j] - ( d[n] - b[n] ) * d[k];
alfa2 = ( b[n] * d[j] - b[n1] * d[k] ) / delta1;
beta2 = ( b[n1] * d[j] - ( d[n] - b[n] ) * b[n] ) / delta1;
alfa1 = alfa1 + alfa2;
beta1 = beta1 + beta2;
if( --limit < 0 )
return;
// cannot solve
if( Math.abs( alfa2 ) < TOLERANCE && Math.abs( beta2 ) < TOLERANCE )
break;
}
while( true );
delta1 = alfa1*alfa1 - 4 * beta1;
if( delta1 < 0 )
// imaginary roots
{
delta2 = Math.sqrt( Math.abs( delta1 ) ) / 2;
delta3 = -alfa1 / 2;
real[count]
imag[count]
= delta3;
= delta2;
real[count+1] = delta3;
imag[count+1] = delta2; // sign is inverted on display
}
else
{
= ( delta2 - alfa1 ) / 2;
= 0;
n = n - 2;
n1 = n1 - 2;
n2 = n2 - 2;
)
)
)
)
)
)
)
)
/
/
/
/
/
/
/
/
100000.0;
100000.0;
100000.0;
100000.0;
100000.0;
100000.0;
100000.0;
100000.0;
document.calc.im_2.value
document.calc.re_3.value
document.calc.im_3.value
document.calc.re_4.value
document.calc.im_4.value
=
=
=
=
=
imag[1];
real[2];
imag[2];
real[3];
imag[3];
}
}
function allclear()
{
document.calc.coeff_a.value='0';
document.calc.coeff_b.value='0';
document.calc.coeff_c.value='0';
document.calc.coeff_d.value='0';
}
// unhide -->
</script>
</head>
<body bgcolor="white" text="black">
<!--[TOP]-->
<center>
<!-- google -->
<script type="text/javascript"><!-google_ad_client = "pub-8195248024094868";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_channel ="";
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/
show_ads.js">
</script>
<!-- google -->
</center>
<!--[END]-->
<hr>
<div class="addthis_toolbox addthis_default_style">
<a href="http://www.addthis.com/bookmark.php?v=250&username=xa-4c2dcb235d3d5
f6f" class="addthis_button_compact">Share</a>
|<a href="../index.html"> home </a>
|<a href="scriptindex.html"> contents </a>
|<a href="#top" onClick=feedback()> send comment </a>
|<a href="#top" onClick=send_to()> send link </a>
|<a href="#top" onClick=bookmark()> add bookmark </a>|
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.
js#username=xa-4c2dcb235d3d5f6f"></script>
<hr>
<h2>Quartic Root Calculator</h2>
<h4>by Stephen R. Schmitt</h4>
<form name="calc">
<blockquote>
<b><tt>
<p>0 =
name="contents">Contents</a></h3>
href="#about">About</a><br>
href="#the source code">The source code</a><br>
href="#discussion">Discussion</a><br>
<hr>
<h4><a name="about">About</a></h4>
<p>This calculator computes complex and real roots for any quartic polynomial. I
t applies the Lin-Bairstow algorithm which iteratively solves for the roots star
ting from random guesses for a solution. The calculator is designed to solve for
the roots of a quartic polynomial with the form:
<p><table align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<td nowrap="nowrap"> <i>x</i><sup>4</sup> + <i>ax</i><sup>3</sup>+ <i>b
x</i><sup>2</sup> + <i>cx</i> + <i>d</i> = 0</td>
</tr>
</table>
<p>The program is operated by entering the coefficients for the quartic polynomi
al to be solved, selecting the rounding option desired, and then pressing the <b
>Calculate</b> button. All entries are cleared by pressing the <b>Clear</b> butt
on. If the value of <i>d</i> is zero (which means that one root is zero), the pr
ogram returns an error message: <b>cannot solve</b>. In this case, the quartic p
olynomial can be reduced to a cubic which cannot be solved using this calculator
; try the <a href="script_cubic.html">Cubic Root Calculator</a>. It is possible
for the initial random guesses used by the algorithm to cause it to be unstable;
the above error message will result in this instance. Each time the algorithm i
s started, a new set of initial random guesses will be generated -- another tria
l may result in a solution.
<p>Return to <a href="#contents">Contents</a>
<hr>
<h4><a name="the source code">The source code</a></h4>
<p>The Java Script source code for this program can be viewed by using the <b>Vi
ew|Source</b> command of your web browser.
<p>You may use or modify this source code in any way you find useful, provided t
hat you agree that the author has no warranty, obligations or liability. You mu
st determine the suitablility of this source code for your use.
<p>Return to <a href="#contents">Contents</a>
<hr>
<h4><a name="discussion">Discussion</a></h4>
<p>A polynomial, <i>P</i>(<i>x</i>), has a factor of (<i>x</i> − <i>r</i>)
if and only if <i>P</i>(<i>r</i>) = 0. Then <i>r</i> is said to be a zero of th
e polynomial.
<p>Every quartic polynomial, <i>P</i>(<i>x</i>), has a factorization of the form
:
<p><table align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<td nowrap="nowrap"> <i>P</i>(<i>x</i>) = (<i>x</i> − <i>r</i><su
b>1</sub>)(<i>x</i> − <i>r</i><sub>2</sub>)(<i>x</i> − <i>r</i><sub>
3</sub>)(<i>x</i> − <i>r</i><sub>4</sub>) = 0</td>
</tr>
</table>
<p>where the roots, <i>r<sub>i</sub></i>, can be duplicates.
<p>If <i>P</i>(<i>x</i>) has real coefficients (as in this calculator), and if <
i>x</i> is a complex zero of <i>P</i>(<i>x</i>), then the complex conjugate of <
i>x</i> is also a zero of <i>P</i>(<i>x</i>). A quartic polynomial can have four
real zeros, or two real zeros and one pair of complex zeros, or two pairs of co
mplex zeros.
<p>Return to <a href="#contents">Contents</a>
<hr>
<div class="addthis_toolbox addthis_default_style">
<a href="http://www.addthis.com/bookmark.php?v=250&username=xa-4c2dcb235d3d5
f6f" class="addthis_button_compact">Share</a>
|<a href="../index.html"> home </a>
|<a href="scriptindex.html"> contents </a>
|<a href="#top" onClick=feedback()> send comment </a>
|<a href="#top" onClick=send_to()> send link </a>
|<a href="#top" onClick=bookmark()> add bookmark </a>|
</div>
<hr>
<!--[BOTTOM]-->
<center>
<!-- google -->
<script type="text/javascript"><!-google_ad_client = "pub-8195248024094868";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_channel ="";
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/
show_ads.js">
</script>
<!-- google -->
</center>
<!--[END]-->
<hr>
Copyright © 2004, Stephen R. Schmitt
</body>
</html>