• Polynomial

# Page History

## Key

• This line was removed.
• Formatting was changed.
Comment: Migrated to Confluence 5.3
Div
style display:none

DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.

Div
id description

HTML Table
id servoy sSummary
Colgroup Tag
Col
width 80px
Col
Table Row (tr)
style height: 30px;
 colspan 2
Method Summary
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
Adds another polynomial to this polynomial.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
Adds a term to this polynomial.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
findRoot(startValue, error, iterations)
Finds a root of this polynomial using Newton's method, starting from an initial search value, and with a given precision.
Table Row (tr)
Table Cell (td)
Polynomial
Table Cell (td)
getDerivative()
Returns a polynomial that holds the derivative of this polynomial.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
getDerivativeValue(x)
Returns the value of the derivative of this polynomial in a certain point.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
getValue(x)
Returns the value of this polynomial in a certain point.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
multiplyByPolynomial(polynomial)
Multiplies this polynomial with another polynomial.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
multiplyByTerm(coefficient, exponent)
Multiples this polynomial with a term.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
setToZero()
Sets this polynomial to zero.

HTML Table
id function servoy sDetail
Colgroup Tag
Col
colspan 2 100%
Col
Table Row (tr)
style height: 30px;
 colspan 2
Method Details
Table Body (tbody)
Table Row (tr)
id name
Table Cell (td)

Table Row (tr)
id sig
Table Cell (td)
Span
style margin-right: 5px;
void
Span
style font-weight: bold;
Span
(polynomial)
Table Row (tr)
id des
Table Cell (td)
Div
class sIndent
Adds another polynomial to this polynomial.
Table Row (tr)
id prs
Table Cell (td)

Parameters

Div
class sIndent
{Polynomial} polynomial
Table Row (tr)
id ret
Table Cell (td)

Returns

Div
class sIndent
void
Table Row (tr)
id sam
Table Cell (td)

Sample

Div
class sIndent
Code Block
language javascript
```// (x+1) + 2*(x+1)*x + 3*(x+1)*x^2 + 4*(x+1)*x^3
var eq = plugins.amortization.newPolynomial();
for (var i = 0; i < 4; i++)
{
var base = plugins.amortization.newPolynomial();
base.multiplyByTerm(1, i);
base.multiplyByTerm(i + 1, 0);
}
application.output(eq.getValue(2));```
Table Row (tr)
class lastDetailRow
Table Cell (td)

Table Body (tbody)
Table Row (tr)
id name
Table Cell (td)

Table Row (tr)
id sig
Table Cell (td)
Span
style margin-right: 5px;
void
Span
style font-weight: bold;
Span
(coefficient, exponent)
Table Row (tr)
id des
Table Cell (td)
Div
class sIndent
Adds a term to this polynomial.
Table Row (tr)
id prs
Table Cell (td)

Parameters

Div
class sIndent
{Number} coefficient
{Number} exponent
Table Row (tr)
id ret
Table Cell (td)

Returns

Div
class sIndent
void
Table Row (tr)
id sam
Table Cell (td)

Sample

Div
class sIndent
Code Block
language javascript
```// (x+1) + 2*(x+1)*x + 3*(x+1)*x^2 + 4*(x+1)*x^3
var eq = plugins.amortization.newPolynomial();
for (var i = 0; i < 4; i++)
{
var base = plugins.amortization.newPolynomial();
base.multiplyByTerm(1, i);
base.multiplyByTerm(i + 1, 0);
}
application.output(eq.getValue(2));```
Table Row (tr)
class lastDetailRow
Table Cell (td)

Table Body (tbody)
id findRoot-Number_Number_Number
Table Row (tr)
id name
Table Cell (td)

#### findRoot

Table Row (tr)
id sig
Table Cell (td)
Span
style margin-right: 5px;
Number
Span
style font-weight: bold;
findRoot
Span
(startValue, error, iterations)
Table Row (tr)
id des
Table Cell (td)
Div
class sIndent
Finds a root of this polynomial using Newton's method, starting from an initial search value, and with a given precision.
Table Row (tr)
id prs
Table Cell (td)

Parameters

Div
class sIndent
{Number} startValue
{Number} error
{Number} iterations
Table Row (tr)
id ret
Table Cell (td)

Returns

Div
class sIndent
Number
Table Row (tr)
id sam
Table Cell (td)

Sample

Div
class sIndent
Code Block
language javascript
```// Model the quadratic equation -x^2 + 4x + 0.6 = 0
var eq = plugins.amortization.newPolynomial();
// Find the roots of the equation.
r1 = eq.findRoot(100, 1E-5, 1000);
r2 = eq.findRoot(-100, 1E-5, 1000);
application.output("eq(" + r1 + ")=" + eq.getValue(r1));
application.output("eq(" + r2 + ")=" + eq.getValue(r2));
// Find the minimum/maximum point by zeroing the first derivative.
var deriv = eq.getDerivative();
rd = deriv.findRoot(0, 1E-5, 1000);
application.output("Min/max point: " + rd);
application.output("Min/max value: " + eq.getValue(rd));
if (deriv.getDerivativeValue(rd) < 0) application.output("Max point.");
else application.output("Min point.");```
Table Row (tr)
class lastDetailRow
Table Cell (td)

Table Body (tbody)
id getDerivative
Table Row (tr)
id name
Table Cell (td)

#### getDerivative

Table Row (tr)
id sig
Table Cell (td)
Span
style margin-right: 5px;
Polynomial
Span
style font-weight: bold;
getDerivative
Span
()
Table Row (tr)
id des
Table Cell (td)
Div
class sIndent
Returns a polynomial that holds the derivative of this polynomial.
Table Row (tr)
id ret
Table Cell (td)

Returns

Div
class sIndent
Polynomial
Table Row (tr)
id sam
Table Cell (td)

Sample

Div
class sIndent
Code Block
language javascript
```// Model the quadratic equation -x^2 + 4x + 0.6 = 0
var eq = plugins.amortization.newPolynomial();
// Find the roots of the equation.
r1 = eq.findRoot(100, 1E-5, 1000);
r2 = eq.findRoot(-100, 1E-5, 1000);
application.output("eq(" + r1 + ")=" + eq.getValue(r1));
application.output("eq(" + r2 + ")=" + eq.getValue(r2));
// Find the minimum/maximum point by zeroing the first derivative.
var deriv = eq.getDerivative();
rd = deriv.findRoot(0, 1E-5, 1000);
application.output("Min/max point: " + rd);
application.output("Min/max value: " + eq.getValue(rd));
if (deriv.getDerivativeValue(rd) < 0) application.output("Max point.");
else application.output("Min point.");```
Table Row (tr)
class lastDetailRow
Table Cell (td)

Table Body (tbody)
id getDerivativeValue-Number
Table Row (tr)
id name
Table Cell (td)

#### getDerivativeValue

Table Row (tr)
id sig
Table Cell (td)
Span
style margin-right: 5px;
Number
Span
style font-weight: bold;
getDerivativeValue
Span
(x)
Table Row (tr)
id des
Table Cell (td)
Div
class sIndent
Returns the value of the derivative of this polynomial in a certain point.
Table Row (tr)
id prs
Table Cell (td)

Parameters

Div
class sIndent
{Number} x
Table Row (tr)
id ret
Table Cell (td)

Returns

Div
class sIndent
Number
Table Row (tr)
id sam
Table Cell (td)

Sample

Div
class sIndent
Code Block
language javascript
```// Model the quadratic equation -x^2 + 4x + 0.6 = 0
var eq = plugins.amortization.newPolynomial();
// Find the roots of the equation.
r1 = eq.findRoot(100, 1E-5, 1000);
r2 = eq.findRoot(-100, 1E-5, 1000);
application.output("eq(" + r1 + ")=" + eq.getValue(r1));
application.output("eq(" + r2 + ")=" + eq.getValue(r2));
// Find the minimum/maximum point by zeroing the first derivative.
var deriv = eq.getDerivative();
rd = deriv.findRoot(0, 1E-5, 1000);
application.output("Min/max point: " + rd);
application.output("Min/max value: " + eq.getValue(rd));
if (deriv.getDerivativeValue(rd) < 0) application.output("Max point.");
else application.output("Min point.");```
Table Row (tr)
class lastDetailRow
Table Cell (td)

Table Body (tbody)
id getValue-Number
Table Row (tr)
id name
Table Cell (td)

#### getValue

Table Row (tr)
id sig
Table Cell (td)
Span
style margin-right: 5px;
Number
Span
style font-weight: bold;
getValue
Span
(x)
Table Row (tr)
id des
Table Cell (td)
Div
class sIndent
Returns the value of this polynomial in a certain point.
Table Row (tr)
id prs
Table Cell (td)

Parameters

Div
class sIndent
{Number} x
Table Row (tr)
id ret
Table Cell (td)

Returns

Div
class sIndent
Number
Table Row (tr)
id sam
Table Cell (td)

Sample

Div
class sIndent
Code Block
language javascript
```// Model the quadratic equation -x^2 + 4x + 0.6 = 0
var eq = plugins.amortization.newPolynomial();
// Find the roots of the equation.
r1 = eq.findRoot(100, 1E-5, 1000);
r2 = eq.findRoot(-100, 1E-5, 1000);
application.output("eq(" + r1 + ")=" + eq.getValue(r1));
application.output("eq(" + r2 + ")=" + eq.getValue(r2));
// Find the minimum/maximum point by zeroing the first derivative.
var deriv = eq.getDerivative();
rd = deriv.findRoot(0, 1E-5, 1000);
application.output("Min/max point: " + rd);
application.output("Min/max value: " + eq.getValue(rd));
if (deriv.getDerivativeValue(rd) < 0) application.output("Max point.");
else application.output("Min point.");```
Table Row (tr)
class lastDetailRow
Table Cell (td)

Table Body (tbody)
id multiplyByPolynomial-Polynomial
Table Row (tr)
id name
Table Cell (td)

#### multiplyByPolynomial

Table Row (tr)
id sig
Table Cell (td)
Span
style margin-right: 5px;
void
Span
style font-weight: bold;
multiplyByPolynomial
Span
(polynomial)
Table Row (tr)
id des
Table Cell (td)
Div
class sIndent
Multiplies this polynomial with another polynomial.
Table Row (tr)
id prs
Table Cell (td)

Parameters

Div
class sIndent
{Polynomial} polynomial
Table Row (tr)
id ret
Table Cell (td)

Returns

Div
class sIndent
void
Table Row (tr)
id sam
Table Cell (td)

Sample

Div
class sIndent
Code Block
language javascript
```// Model the quadratic equation (x+1)*(x+2) = 0
var eq = plugins.amortization.newPolynomial();
var eq2 = plugins.amortization.newPolynomial();
eq.multiplyByPolynomial(eq2);
// Find the roots of the equation.
r1 = eq.findRoot(100, 1E-5, 1000);
r2 = eq.findRoot(-100, 1E-5, 1000);
application.output("eq(" + r1 + ")=" + eq.getValue(r1));
application.output("eq(" + r2 + ")=" + eq.getValue(r2));```
Table Row (tr)
class lastDetailRow
Table Cell (td)

Table Body (tbody)
id multiplyByTerm-Number_Number
Table Row (tr)
id name
Table Cell (td)

#### multiplyByTerm

Table Row (tr)
id sig
Table Cell (td)
Span
style margin-right: 5px;
void
Span
style font-weight: bold;
multiplyByTerm
Span
(coefficient, exponent)
Table Row (tr)
id des
Table Cell (td)
Div
class sIndent
Multiples this polynomial with a term.
Table Row (tr)
id prs
Table Cell (td)

Parameters

Div
class sIndent
{Number} coefficient
{Number} exponent
Table Row (tr)
id ret
Table Cell (td)

Returns

Div
class sIndent
void
Table Row (tr)
id sam
Table Cell (td)

Sample

Div
class sIndent
Code Block
language javascript
```// (x+1) + 2*(x+1)*x + 3*(x+1)*x^2 + 4*(x+1)*x^3
var eq = plugins.amortization.newPolynomial();
for (var i = 0; i < 4; i++)
{
var base = plugins.amortization.newPolynomial();
base.multiplyByTerm(1, i);
base.multiplyByTerm(i + 1, 0);
}
application.output(eq.getValue(2));```
Table Row (tr)
class lastDetailRow
Table Cell (td)

Table Body (tbody)
id setToZero
Table Row (tr)
id name
Table Cell (td)

#### setToZero

Table Row (tr)
id sig
Table Cell (td)
Span
style margin-right: 5px;
void
Span
style font-weight: bold;
setToZero
Span
()
Table Row (tr)
id des
Table Cell (td)
Div
class sIndent
Sets this polynomial to zero.
Table Row (tr)
id ret
Table Cell (td)

Returns

Div
class sIndent
void
Table Row (tr)
id sam
Table Cell (td)

Sample

Div
class sIndent
Code Block
language javascript
```var eq = plugins.amortization.newPolynomial();