Numeric solvers

(directly go to documentation on : Newton, FindRealRoots, NumRealRoots, MinimumBound, MaximumBound. )

# 13. Numeric solvers

Newton | solve an equation numerically with Newton's method
FindRealRoots | find the real roots of a polynomial
NumRealRoots | return the number of real roots of a polynomial
MinimumBound | return lower bounds on the absolute values of real roots of a polynomial
MaximumBound | return upper bounds on the absolute values of real roots of a polynomial

###

Newton -- solve an equation numerically with Newton's method

##### Standard library

##### Calling format:

    Newton(expr, var, initial, accuracy)
    Newton(expr, var, initial, accuracy,min,max)

##### Parameters:

`expr` -- an expression to find a zero for

`var` -- free variable to adjust to find a zero

`initial` -- initial value for "var" to use in the search

`accuracy` -- minimum required accuracy of the result

`min` -- minimum value for "var" to use in the search

`max` -- maximum value for "var" to use in the search

##### Description:

This function tries to numerically find a zero of the expression `expr`, which should depend only on the variable `var`. It uses the value `initial` as an initial guess.

The function will iterate using Newton's method until it estimates that it has come within a distance `accuracy` of the correct solution, and then it will return its best guess. In particular, it may loop forever if the algorithm does not converge.

When `min` and `max` are supplied, the Newton iteration takes them into account by returning `Fail` if it failed to find a root in the given range. Note this doesn't mean there isn't a root, just that this algorithm failed to find it due to the trial values going outside of the bounds.

##### Examples:

    In> Newton(Sin(x),x,3,0.0001)
    Out> 3.1415926535;
    In> Newton(x^2-1,x,2,0.0001,-5,5)
    Out> 1;
    In> Newton(x^2+1,x,2,0.0001,-5,5)
    Out> Fail;

##### See also:

Solve , NewtonNum .

###

FindRealRoots -- find the real roots of a polynomial

##### Standard library

##### Calling format:

    FindRealRoots(p)

##### Parameters:

`p` - a polynomial in `x`

##### Description:

Return a list with the real roots of p. It tries to find the real-valued roots, and thus requires numeric floating point calculations. The precision of the result can be improved by increasing the calculation precision.

##### Examples:

    In> p:=Expand((x+3.1)^5*(x-6.23))
    Out> x^6+9.27*x^5-0.465*x^4-300.793*x^3-
    1394.2188*x^2-2590.476405*x-1783.5961073;
    In> FindRealRoots(p)
    Out> {-3.1,6.23};

##### See also:

SquareFree , NumRealRoots , MinimumBound , MaximumBound , Factor .

###

NumRealRoots -- return the number of real roots of a polynomial

##### Standard library

##### Calling format:

    NumRealRoots(p)

##### Parameters:

`p` - a polynomial in `x`

##### Description:

Returns the number of real roots of a polynomial p. The polynomial must use the variable `x` and no other variables.

##### Examples:

    In> NumRealRoots(x^2-1)
    Out> 2;
    In> NumRealRoots(x^2+1)
    Out> 0;

##### See also:

FindRealRoots , SquareFree , MinimumBound , MaximumBound , Factor .

###

MinimumBound -- return lower bounds on the absolute values of real roots of a polynomial

###

MaximumBound -- return upper bounds on the absolute values of real roots of a polynomial

##### Standard library

##### Calling format:

    MinimumBound(p)
    MaximumBound(p)

##### Parameters:

`p` - a polynomial in x

##### Description:

Return minimum and maximum bounds for the absolute values of the real roots of a polynomial `p`. The polynomial has to be converted to one with rational coefficients first, and be made square-free. The polynomial must use the variable `x`.

##### Examples:

    In> p:=SquareFree(Rationalize((x-3.1)*(x+6.23)))
    Out> (-40000*x^2-125200*x+772520)/870489;
    In> MinimumBound(p)
    Out> 5000000000/2275491039;
    In> N(%)
    Out> 2.1973279236;
    In> MaximumBound(p)
    Out> 10986639613/1250000000;
    In> N(%)
    Out> 8.7893116904;

##### See also:

SquareFree , NumRealRoots , FindRealRoots , Factor .