Previous Page Next Page Contents

numeric::solve -- numerical solution of equations (the float attribute of solve)

Introduction

numeric::solve computes numerical solutions of equations.

Call(s)

numeric::solve(eqs, <, vars> <, Options>)
float(hold(solve)(eqs, <, vars> <, Options>))

float(freeze(solve)(eqs, <, vars> <, Options>))

Parameters

eqs - an equation, a list of equations, or a set of equations. Also arithmetical expressions are accepted and interpreted as homogeneous equations.

Options

vars - an unknown, a list of unknowns or a set of unknowns. Unknowns may be identifiers or indexed identifiers. Also equations of the form x=a or x=a..b are accepted wherever an unknown x is expected. This way starting points and search ranges are specified for the numerical search. They must be numerical, infinite search ranges are accepted.
Options - a combination of Multiple, FixedPrecision, SquareFree, Factor, RestrictedSearch, or Random
Multiple - only to be used if eqs is a polynomial equation or a system of polynomial equations. With this option, information on the multiplicity of degenerate polynomial roots is returned.
FixedPrecision - only to be used if eqs is a single univariate polynomial. It launches a quick numerical search with fixed internal precision.
SquareFree - only to be used if eqs is a single univariate polynomial. Symbolic square free factorization is applied, before the numerical search starts.
Factor - only to be used if eqs is a single univariate polynomial. Symbolic factorization is applied, before the numerical search starts.
RestrictedSearch - only to be used for non-polynomial equations. The numerical search is restricted to the search ranges specified in vars.
Random - only to be used for non-polynomial equations. With this option, several calls to numeric::solve may lead to different solutions of the equation(s).

Returns

a set of numerical solutions. With the option Multiple, a set of domain type Dom::Multiset is returned.

Side Effects

The function is sensitive to the environment variable DIGITS, which determines the numerical working precision.

Related Functions

linsolve, numeric::fsolve, numeric::linsolve, numeric::polyroots, numeric::polysysroots, numeric::realroot, numeric::realroots, polylib::realroots, solve

Details

Option: vars

Option: Multiple

Option: FixedPrecision

Option: SquareFree

Option: Factor

Option: RestrictedSearch

Option: Random

Example 1

The following three calls are equivalent:

>> eqs := {x^2 = sin(y), y^2 = cos(x)}:
>> numeric::solve(eqs, {x, y}),
   float(hold(solve)(eqs, {x, y})),
   float(freeze(solve)(eqs, {x,y}))
      {[y = 0.8116062152, x = 0.8517004887]},
      
         {[y = 0.8116062152, x = 0.8517004887]},
      
         {[y = 0.8116062152, x = 0.8517004887]}
>> delete eqs:

Example 2

We demonstrate the root search for univariate polynomials:

>> numeric::solve(x^6 - PI*x^2 = sin(3), x)
      {-1.339589767, 1.339589767, - 1.322706295 I, - 0.2120113223 I,
      
         0.2120113223 I, 1.322706295 I}

Polynomials of type DOM_POLY can be used as input:

>> numeric::solve(poly((x - 1/3)^3, [x]), x)
                              {0.3333333333}

With Multiple, a Dom::Multiset is returned, indicating the multiplicity of the root:

>> numeric::solve(x^3 - x^2 + x/3 -1/27, x, Multiple)
                            {[0.3333333333, 3]}

Example 3

We demonstrate the root search for polynomial systems. Note that the symbolic solver solve is involved. Symbolic parameters are accepted:

>> numeric::solve({x^2 + y^2 = 1, x^2 - y^2 = exp(z)}, {x, y})
                                             1/2
      {[y = - 0.7071067812 (1.0 - 1.0 exp(z))   ,
      
                                          1/2
         x = - 0.7071067812 (exp(z) + 1.0)   ],
      
         ...
                                             1/2
         [y = 0.7071067812 (1.0 - 1.0 exp(z))   ,
      
                                        1/2
         x = 0.7071067812 (exp(z) + 1.0)   ]}

Example 4

We demonstrate the root search for non-polynomial equations.

>> eq := exp(-x) - 10*x^2:
>> numeric::solve(eq, x)
                              {0.2755302947}

Since numeric::solve just calls the root finder numeric::fsolve, one may also use this routine directly. Note the different output format:

>> numeric::fsolve(eq, x)
                            [x = 0.2755302947]

The input syntax of numeric::solve and numeric::fsolve are identical, i.e., starting points, search ranges and options may be used. E.g., another solution of the previous equation is found by a restricted search over the interval [-1,0]:

>> numeric::solve(eq, x = -1..0, RestrictedSearch)
                              {-0.3829657727}

The following search for a solution in the entire 2-dimensional plane fails:

>> eqs := [exp(x) = 2*y^2, sin(y) = y*x^3]:
>> numeric::solve(eqs, [x, y])
                                   {[]}

Assisted by starting points for the internal search a solution is found:

>> numeric::solve(eqs, [x = 1, y = 1.5])
                   {[x = 0.9290711315, y = 1.125201325]}

Another solution with negative y is found with an appropriate search range:

>> numeric::solve(eqs, [x = 1, y = -infinity..0])
                  {[x = 0.9290711314, y = -1.125201325]}
>> delete eq, eqs:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000