Child pages
  • Polynomial

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
{div:style=}
Wiki Markup
Div
styledisplay: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} {div:id=description}{div}\\ {table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}void{td}{td}[#addPolynomial]\(polynomial) Adds another polynomial to this polynomial.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#addTerm]\(coefficient, exponent) Adds a term to this polynomial.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{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.{td}{tr}{tbody}{tbody}{tr}{td}[Polynomial]{td}{td}[#getDerivative]\() Returns a polynomial that holds the derivative of this polynomial.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{td}[#getDerivativeValue]\(x) Returns the value of the derivative of this polynomial in a certain point.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{td}[#getValue]\(x) Returns the value of this polynomial in a certain point.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#multiplyByPolynomial]\(polynomial) Multiplies this polynomial with another polynomial.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#multiplyByTerm]\(coefficient, exponent) Multiples this polynomial with a term.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#setToZero]\() Sets this polynomial to zero.{td}{tr}{tbody}{table}\\ {table:id=function|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=addPolynomial-Polynomial}{tr:id=name}{td}h6.addPolynomial{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}void{span}{span:style=font-weight: bold;}addPolynomial{span}{span}\(polynomial){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[Polynomial]} polynomial {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}void{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}

.

Div
iddescription



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
addPolynomial(polynomial)
Adds another polynomial to this polynomial.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
addTerm(coefficient, exponent)
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
idfunction
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
idaddPolynomial-Polynomial
Table Row (tr)
idname
Table Cell (td)

addPolynomial

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
addPolynomial
Span
(polynomial)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Adds another polynomial to this polynomial.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Polynomial} polynomial
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// (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.addTerm(1, 1);
	base.addTerm(1, 0);
	base.multiplyByTerm(1, i);
	base.multiplyByTerm(i + 1, 0);
	eq.addPolynomial(base);
}
application.output(eq.getValue(2));
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idaddTerm-Number_Number
}{
Table Row (tr)
:
id
=
name
}{td}h6.addTerm{td}{tr}{tr:id=sig}{td}{span:style=
Table Cell (td)

addTerm

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right:
5px;
}
void
{span}{span:style=
Span
stylefont-weight:
bold;
}
addTerm
{span}{span}\
Span
(coefficient,
exponent)
{span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[Number]} coefficient \{[Number]} exponent {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}void{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Adds a term to this polynomial.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Number} coefficient
{Number} exponent
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// (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.addTerm(1, 1);
	base.addTerm(1, 0);
	base.multiplyByTerm(1, i);
	base.multiplyByTerm(i + 1, 0);
	eq.addPolynomial(base);
}
application.output(eq.getValue(2));
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idfindRoot-Number_Number_Number
}{
Table Row (tr)
:
id
=
name
}{td}h6.findRoot{td}{tr}{tr:id=sig}{td}{span:style=
Table Cell (td)

findRoot

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right:
5px;
}[
Number
]{span}{span:style=
Span
stylefont-weight:
bold;
}
findRoot
{span}{span}\
Span
(startValue,
error,
iterations)
{span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[Number]} startValue \{[Number]} error \{[Number]} iterations {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Number]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Finds a root of this polynomial using Newton's method, starting from an initial search value, and with a given precision.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Number} startValue
{Number} error
{Number} iterations
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// Model the quadratic equation -x^2 + 4x + 0.6 = 0
var eq = plugins.amortization.newPolynomial();
eq.addTerm(-1, 2);
eq.addTerm(4, 1);
eq.addTerm(0.6, 0);
// 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.");
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getDerivative}{tr:id=name}{td}h6.getDerivative{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Polynomial]{span}{span:style=font-weight: bold;}getDerivative{span}{span}\(){span}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Polynomial]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetDerivative
Table Row (tr)
idname
Table Cell (td)

getDerivative

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Polynomial
Span
stylefont-weight: bold;
getDerivative
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns a polynomial that holds the derivative of this polynomial.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Polynomial
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// Model the quadratic equation -x^2 + 4x + 0.6 = 0
var eq = plugins.amortization.newPolynomial();
eq.addTerm(-1, 2);
eq.addTerm(4, 1);
eq.addTerm(0.6, 0);
// 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.");
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getDerivativeValue-Number}{tr:id=name}{td}h6.getDerivativeValue{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Number]{span}{span:style=font-weight: bold;}getDerivativeValue{span}{span}\(x){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[Number]} x {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Number]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetDerivativeValue-Number
Table Row (tr)
idname
Table Cell (td)

getDerivativeValue

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Number
Span
stylefont-weight: bold;
getDerivativeValue
Span
(x)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns the value of the derivative of this polynomial in a certain point.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Number} x
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// Model the quadratic equation -x^2 + 4x + 0.6 = 0
var eq = plugins.amortization.newPolynomial();
eq.addTerm(-1, 2);
eq.addTerm(4, 1);
eq.addTerm(0.6, 0);
// 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.");
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getValue-Number}{tr:id=name}{td}h6.getValue{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Number]{span}{span:style=font-weight: bold;}getValue{span}{span}\(x){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[Number]} x {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Number]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetValue-Number
Table Row (tr)
idname
Table Cell (td)

getValue

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Number
Span
stylefont-weight: bold;
getValue
Span
(x)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns the value of this polynomial in a certain point.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Number} x
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// Model the quadratic equation -x^2 + 4x + 0.6 = 0
var eq = plugins.amortization.newPolynomial();
eq.addTerm(-1, 2);
eq.addTerm(4, 1);
eq.addTerm(0.6, 0);
// 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.");
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=multiplyByPolynomial-Polynomial}{tr:id=name}{td}h6.multiplyByPolynomial{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}void{span}{span:style=font-weight: bold;}multiplyByPolynomial{span}{span}\(polynomial){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[Polynomial]} polynomial {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}void{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idmultiplyByPolynomial-Polynomial
Table Row (tr)
idname
Table Cell (td)

multiplyByPolynomial

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
multiplyByPolynomial
Span
(polynomial)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Multiplies this polynomial with another polynomial.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Polynomial} polynomial
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// Model the quadratic equation (x+1)*(x+2) = 0
var eq = plugins.amortization.newPolynomial();
eq.addTerm(1, 1);
eq.addTerm(1, 0);
var eq2 = plugins.amortization.newPolynomial();
eq2.addTerm(1, 1);
eq2.addTerm(2, 0);
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)); {code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=
r2));
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idmultiplyByTerm-Number_Number
}{
Table Row (tr)
:
id
=
name
}{td}h6.multiplyByTerm{td}{tr}{tr:id=sig}{td}{span:style=
Table Cell (td)

multiplyByTerm

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right:
5px;
}
void
{span}{span:style=
Span
stylefont-weight:
bold;
}
multiplyByTerm
{span}{span}\
Span
(coefficient,
exponent)
{span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[Number]} coefficient \{[Number]} exponent {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}void{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Multiples this polynomial with a term.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Number} coefficient
{Number} exponent
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// (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.addTerm(1, 1);
	base.addTerm(1, 0);
	base.multiplyByTerm(1, i);
	base.multiplyByTerm(i + 1, 0);
	eq.addPolynomial(base);
}
application.output(eq.getValue(2));
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=setToZero}{tr:id=name}{td}h6.setToZero{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}void{span}{span:style=font-weight: bold;}setToZero{span}{span}\(){span}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}void{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsetToZero
Table Row (tr)
idname
Table Cell (td)

setToZero

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
setToZero
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Sets this polynomial to zero.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var eq = plugins.amortization.newPolynomial();
eq.addTerm(2, 3);
application.output(eq.getValue(1.1));
eq.setToZero();
application.output(eq.getValue(1.1));
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}
Table Row (tr)
classlastDetailRow
Table Cell (td)