Re: solve f(x)=0, where f:Rn+1 -> Rn
- To: mathgroup at smc.vnet.net
- Subject: [mg26212] Re: [mg26189] solve f(x)=0, where f:Rn+1 -> Rn
- From: "Carl K. Woll" <carlw at u.washington.edu>
- Date: Sat, 2 Dec 2000 02:10:39 -0500 (EST)
- References: <200012010302.WAA11186@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Pavel,
A while back I put forth a function which I believe does exactly what you
want. The function is called ImplicitSolve, and it has the usage message:
?ImplicitSolve
ImplicitSolve[eqns, {x->x0,y->y0,...}, {x, xmin, xmax},
opts] finds a solution to the implicit equations eqns
for the functions y, ... with the independent
variable x in the range xmin to xmax. The root
{x0,y0,...} should satisfy the equations, or should
provide a good starting point for finding a solution
when using FindRoot. Currently, the only available
option is AccuracyGoal, but a better ImplicitSolve
would include the possibility of supplying options
for both the FindRoot and NDSolve function calls.
I will give the function definition at the end of this message (modified
slightly from my previous post).
For your circle example, you would use ImplicitSolve in the following way:
ImplicitSolve[{x^2 + y^2 == 1},
{x -> 0, y -> 1}, {x, -1, 1},
AccuracyGoal -> 10]
and Mathematica would return an interpolating function for y as a function
of x, with an error of about 10^-8.
Carl Woll
Physics Dept
U of Washington
Here is the definition of ImplicitSolve:
Clear[ImplicitSolve]
Options[ImplicitSolve]={AccuracyGoal->6};
ImplicitSolve[eqn_List,rt_,{x_,min_,max_},opts___?OptionQ]:=Module[{x0,y,y0,
acc},
(* options *)
acc=AccuracyGoal/.{opts}/.Options[ImplicitSolve];
(* root *)
x0=Cases[rt,(x->a_)->a];
If[x0=={},
Message[ImplicitSolve::badroot,x];Return[],
x0=x0[[1]]];
{y,y0}=Transpose[DeleteCases[rt,x->x0]/.Rule->List];
(* check root *)
If[!(And@@Thread[Abs[eqn/.Equal->Subtract/.rt]<10^-acc]),
Message[ImplicitSolve::inaccurate];
y0=FindRoot[
Evaluate[eqn/.x->x0],
Evaluate[Sequence@@(Transpose[{y,y0}])],opts][[All,2]],
Null,
Message[ImplicitSolve::incomplete];Return[]
];
(* get interpolating function *)
NDSolve[
Flatten[{D[eqn/.Thread[Rule[y,#[x]&/@y]],x],Thread[#[x0]&/@y==y0]}],
y,
{x,min,max},
AccuracyGoal->acc
PrecisionGoal->acc]
]
ImplicitSolve::usage="ImplicitSolve[eqns, {x->x0,y->y0,...}, {x, xmin,
xmax}, opts] finds a solution to the implicit equations eqns for the
functions y, ... with the independent variable x in the range xmin to xmax.
The root {x0,y0,...} should satisfy the equations, or should provide a good
starting point for finding a solution when using FindRoot. Currently, the
only available option is AccuracyGoal, but a better ImplicitSolve would
include the possibility of supplying options for both the FindRoot and
NDSolve function calls.";
ImplicitSolve::badroot="Supplied root is missing value for `1`";
ImplicitSolve::incomplete="Supplied root is incomplete";
ImplicitSolve::inaccurate="Supplied root is inaccurate, using FindRoot to
improve accuracy";
----- Original Message -----
From: <Pavel.Pokorny at vscht.cz>
To: mathgroup at smc.vnet.net
Subject: [mg26212] [mg26189] solve f(x)=0, where f:Rn+1 -> Rn
> Dear Mathematica friends
>
> Is there a way in Mathematica 4.0 to solve (numerically) the problem
> f(x) = 0
> where f: R^{n+1} -> R^n,
> i.e. f has n+1 real arguments and n real results ?
>
> The solution is (under certain conditions on f)
> a curve in (n+1)-dim space.
>
> Example
> x^2 + y^2 - 1 = 0
> is a unit circle.
>
> This problem is called "continuation" in nonlinear system analysis
> see
> Seydel: Tutorial on Continuation
> Int.J.Bif.Chaos, Vol.1 No.1 (1991) pp 3-11.
>
> --
> Pavel Pokorny
> Math Dept, Prague Institute of Chemical Technology
> http://staff.vscht.cz/mat/Pavel.Pokorny
>