[Date Index]
[Thread Index]
[Author Index]
Re: FindRoot syntax?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg66537] Re: [mg66507] FindRoot syntax?
*From*: "Chris Chiasson" <chris at chiasson.name>
*Date*: Fri, 19 May 2006 03:39:47 -0400 (EDT)
*References*: <200605170730.DAA09191@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
AES,
A three part response for you to peruse:
1)
Personally, I think the syntax is fine. The setup would break if g had
a value, but then g[x,y] couldn't be called normally.
2)
You might consider exploiting the structure of expressions returned by
FindRoot, especially for the one variable case. It would be easy to
use Part to take the right hand side of the rule for g.
3)
You may find it easier (faster?) to express g as the solution to a
differential equation system instead of as a delayed rule involving
FindRoot. This has the advantage of making sure your equations do not
"jump" solutions. Carl Woll told me about this on the MathGroup. It is
called homotopic continuation.
In your case, I think the differential equations could be created as
follows (in a somewhat verbose manner for clarity). Note that I am
just typing this - I haven't tested it because I don't have the
definition of f.
eqns=And[
D[f[g[x,y],x,y]==0,x],
D[f[g[x,y],x,y]==0,y],
f[g[1,y],1,y]==0(*taking x=1 to be one of the starting points*),
f[g[x,2],x,2]==0(*taking y=2 to be the other starting point*)
]
gsolution=NDSolve[eqns,g,{x,xmin,xmax},{y,ymin,ymax}]
(I only show NDSolve here, because your use of FindRoot above seems to
indicate that f has some complexity which may prevent you from
obtaining a solution from DSolve)
Kind Regards,
On 5/17/06, AES <siegman at stanford.edu> wrote:
> I just defined an expression making use of FindRoot[] in the form
>
> g[x_,y_] := g /. FindRoot[ f[g, x, y]==0, {g, 0, 1} ]
>
> where f[g,x,y] is a simple expression involving g, x, and y, and it
> seems to work just fine, churning out numerical values of g[x,y] for
> numerical inputs of x and y, with no obvious problems.
>
> I keep feeling guilty, however, as if I've done something sinful --
> specifically that I should be using a different symbol name or dummy
> variable in place of g on the right-hand side.
>
> Is this syntax really OK?
>
>
--
http://chris.chiasson.name/
Prev by Date:
**Re: fixing contours**
Next by Date:
**Re: NonlinearFit problem**
Previous by thread:
** FindRoot syntax?**
Next by thread:
**fixing contours**
| |