CubicFormula (p)
Calcule les racines d'un polynôme cubique (de degré 3) en utilisant la formule cubique. Le polynôme doit être fourni sous la forme d'un vecteur de coefficients. Par exemple 4*x^3 + 2*x + 1
correspond au vecteur [1,2,0,4]
. Renvoie un vecteur colonne contenant les trois solutions. La première solution est toujours celle qui est réelle puisqu'un polynôme cubique possède toujours une solution réelle.
See Planetmath, Mathworld, or Wikipedia for more information.
EulersMethod (f,x0,y0,x1,n)
Use classical Euler's method to numerically solve y'=f(x,y) for
initial x0
, y0
going to
x1
with n
increments,
returns y
at x1
.
Unless you explicitly want to use Euler's method, you should really
think about using
RungeKutta
for solving ODE.
Les systèmes peuvent être résolus en ayant uniquement y
sous la forme d'un vecteur (colonne) partout. C'est-à-dire y0
peut être un vecteur et dans ce cas f
doit prendre un nombre x
et un vecteur de la même taille comme deuxième argument et doit renvoyer un vecteur de la même taille.
EulersMethodFull (f,x0,y0,x1,n)
Use classical Euler's method to numerically solve y'=f(x,y) for
initial x0
, y0
going to
x1
with n
increments,
returns an n+1
by 2 matrix with the
x
and y
values.
Unless you explicitly want to use Euler's method, you should really
think about using
RungeKuttaFull
for solving ODE.
Suitable
for plugging into
LinePlotDrawLine or
LinePlotDrawPoints.
Example:
genius>
LinePlotClear();
genius>
line = EulersMethodFull(`(x,y)=y,0,1.0,3.0,50);
genius>
LinePlotDrawLine(line,"window","fit","color","blue","legend","Exponential growth");
Les systèmes peuvent être résolus en ayant uniquement y
sous la forme d'un vecteur (colonne) partout. C'est-à-dire y0
peut être un vecteur et dans ce cas f
doit prendre un nombre x
et un vecteur de la même taille comme deuxième argument et doit renvoyer un vecteur de la même taille.
The output for a system is still a n by 2 matrix with the second entry being a vector. If you wish to plot the line, make sure to use row vectors, and then flatten the matrix with ExpandMatrix, and pick out the right columns. Example:
genius>
LinePlotClear();
genius>
lines = EulersMethodFull(`(x,y)=[y@(2),-y@(1)],0,[1.0,1.0],10.0,500);
genius>
lines = ExpandMatrix(lines);
genius>
firstline = lines@(,[1,2]);
genius>
secondline = lines@(,[1,3]);
genius>
LinePlotWindow = [0,10,-2,2];
genius>
LinePlotDrawLine(firstline,"color","blue","legend","First");
genius>
LinePlotDrawPoints(secondline,"color","red","thickness",3,"legend","Second");
See Mathworld or Wikipedia for more information.
Version 1.0.10 onwards.
FindRootBisection (f,a,b,TOL,N)
Find root of a function using the bisection method.
a
and b
are the initial guess interval,
f(a)
and f(b)
should have opposite signs.
TOL
is the desired tolerance and
N
is the limit on the number of iterations to run, 0 means no limit. The function returns a vector [success,value,iteration]
, where success
is a boolean indicating success, value
is the last value computed, and iteration
is the number of iterations done.
FindRootFalsePosition (f,a,b,TOL,N)
Find root of a function using the method of false position.
a
and b
are the initial guess interval,
f(a)
and f(b)
should have opposite signs.
TOL
is the desired tolerance and
N
is the limit on the number of iterations to run, 0 means no limit. The function returns a vector [success,value,iteration]
, where success
is a boolean indicating success, value
is the last value computed, and iteration
is the number of iterations done.
FindRootMullersMethod (f,x0,x1,x2,TOL,N)
Cherche la racine d'une fonction en utilisant la méthode de Muller. TOL
est la tolérance permise et N
est la limite du nombre d'itérations réalisées, 0 signifiant pas de limite. La fonction renvoie un vecteur [succes,valeur,itération]
dans lequel succes
est un booléen indiquant la réussite, valeur
est la dernière valeur calculée et itération
est le nombre d'itérations réalisées.
FindRootSecant (f,a,b,TOL,N)
Find root of a function using the secant method.
a
and b
are the initial guess interval,
f(a)
and f(b)
should have opposite signs.
TOL
is the desired tolerance and
N
is the limit on the number of iterations to run, 0 means no limit. The function returns a vector [success,value,iteration]
, where success
is a boolean indicating success, value
is the last value computed, and iteration
is the number of iterations done.
HalleysMethod (f,df,ddf,guess,epsilon,maxn)
Find zeros using Halley's method. f
is
the function, df
is the derivative of
f
, and ddf
is the second derivative of
f
. guess
is the initial
guess. The function returns after two successive values are
within epsilon
of each other, or after maxn
tries, in which case the function returns null
indicating failure.
See also NewtonsMethod
and SymbolicDerivative
.
Example to find the square root of 10:
genius>
HalleysMethod(`(x)=x^2-10,`(x)=2*x,`(x)=2,3,10^-10,100)
See Wikipedia for more information.
Version 1.0.18 onwards.
NewtonsMethod (f,df,guess,epsilon,maxn)
Find zeros using Newton's method. f
is
the function and df
is the derivative of
f
. guess
is the initial
guess. The function returns after two successive values are
within epsilon
of each other, or after maxn
tries, in which case the function returns null
indicating failure.
See also NewtonsMethodPoly
and SymbolicDerivative
.
Example to find the square root of 10:
genius>
NewtonsMethod(`(x)=x^2-10,`(x)=2*x,3,10^-10,100)
See Wikipedia for more information.
Version 1.0.18 onwards.
PolynomialRoots (p)
Calcule les racines d'un polynôme (de degré 1 à 4) en utilisant une des formules adaptée à ce type de polynôme. Le polynôme doit être fourni sous la forme d'un vecteur de coefficients. Par exemple 4*x^3 + 2*x + 1
correspond au vecteur [1,2,0,4]
. Renvoie un vecteur colonne contenant les solutions.
La fonction appelle QuadraticFormula, CubicFormula et QuarticFormula.
QuadraticFormula (p)
Calcule les racines d'un polynôme quadratique (de degré 2) en utilisant la formule quadratique. Le polynôme doit être fourni sous la forme d'un vecteur de coefficients. 3*x^2 + 2*x + 1
correspond au vecteur [1,2,3]
. Renvoie un vecteur colonne contenant les deux solutions.
See Planetmath, or Mathworld, or Wikipedia for more information.
QuarticFormula (p)
Calcule les racines d'un polynôme quartique (de degré 4) en utilisant la formule quartique. Le polynôme doit être fourni sous la forme d'un vecteur de coefficients. 5*x^4 + 2*x + 1
correspond au vecteur [1,2,0,0,5]
. Renvoie un vecteur colonne contenant les quatre solutions.
See Planetmath, Mathworld, or Wikipedia for more information.
RungeKutta (f,x0,y0,x1,n)
Utilise la méthode classique non adaptative de Runge-Kutta du quatrième ordre pour résoudre numériquement y'=f(x,y) avec les valeurs initiales x0
, y0
allant vers x1
avec n
incréments, renvoie y
en x1
.
Les systèmes peuvent être résolus en ayant uniquement y
sous la forme d'un vecteur (colonne) partout. C'est-à-dire y0
peut être un vecteur et dans ce cas f
doit prendre un nombre x
et un vecteur de la même taille comme deuxième argument et doit renvoyer un vecteur de la même taille.
RungeKuttaFull (f,x0,y0,x1,n)
Use classical non-adaptive fourth order Runge-Kutta method to
numerically solve
y'=f(x,y) for initial x0
, y0
going to x1
with n
increments,
returns an n+1
by 2 matrix with the
x
and y
values. Suitable
for plugging into
LinePlotDrawLine or
LinePlotDrawPoints.
Example:
genius>
LinePlotClear();
genius>
line = RungeKuttaFull(`(x,y)=y,0,1.0,3.0,50);
genius>
LinePlotDrawLine(line,"window","fit","color","blue","legend","Exponential growth");
Les systèmes peuvent être résolus en ayant uniquement y
sous la forme d'un vecteur (colonne) partout. C'est-à-dire y0
peut être un vecteur et dans ce cas f
doit prendre un nombre x
et un vecteur de la même taille comme deuxième argument et doit renvoyer un vecteur de la même taille.
The output for a system is still a n by 2 matrix with the second entry being a vector. If you wish to plot the line, make sure to use row vectors, and then flatten the matrix with ExpandMatrix, and pick out the right columns. Example:
genius>
LinePlotClear();
genius>
lines = RungeKuttaFull(`(x,y)=[y@(2),-y@(1)],0,[1.0,1.0],10.0,100);
genius>
lines = ExpandMatrix(lines);
genius>
firstline = lines@(,[1,2]);
genius>
secondline = lines@(,[1,3]);
genius>
LinePlotWindow = [0,10,-2,2];
genius>
LinePlotDrawLine(firstline,"color","blue","legend","First");
genius>
LinePlotDrawPoints(secondline,"color","red","thickness",3,"legend","Second");
See Mathworld or Wikipedia for more information.
Version 1.0.10 onwards.