Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4703
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: ODE system - shooting for a terminal point |
| Date | 2011-09-02 07:31 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j3q0np$6f0$1@smc.vnet.net> (permalink) |
| References | <j3l17d$btv$1@smc.vnet.net> |
On 31/08/2011 11:08, The Mighty Algernon wrote:
> Hi,
>
> I wonder if you could help me.
>
> I have a system of ODE in which I have to figure out the initial
> conditions of part of the differential equations. I managed to do this
> by the shooting method by writing the system as a function of the
> initial conditions.
>
> For example solution[yini_,zini_]:=NDSolve[......
>
> then I used FindRoot on the set of terminal restrictions to find yini
> and zini (these are the initial conditions). This procedure worked
> although it is terribly sensitive to the first guesses on the FindRoot
> and some results I get are obviously wrong. But this is something I
> can refine.
>
> Now I have a similar goal but the variable I'm trying to guess is not
> an initial condition of a differential equation but the terminal value
> of the range of the exogenous variable. For example,
>
> If I have a system of 2 ODE , y[x] and z[x], I want to know for {x,
> 0,xtarget} what is my xtarget. Think of x as time and I want to figure
> when is the terminal time of the system such that some restrictions at
> the terminal time are met.
>
> My first ideia was to adapt the above procedure, writing
>
> solution[xtarget_]:=NDSolve[......
> then giving the set of restrictions and then using FindRoot to get
> xtarget, but Mathematica gives me an error message the xtarget is not
> a real value.
>
>
> My question is :
>
> Is it possible to adapt the procedure outlined above, meaning that
> I'm just doing some kind of error here (that I'll have to correct), or
> Mathematica does not handle this kind of problems directly in NDSolve
> and I have to write some sort of loop with ever more refined guesses
> for xtarget?
>
> My best regards
>
> Joao Pereira
>
I think what you are asking, boils down to the problem of how to find a
root of f[x] when f[x], itself faults when x has no value - e.g. because
it contains an NDSolve.
The solution is to wrap f[x] in something that will prevent evaluation
unless x is numeric - e.g.
SetAttributes[g,HoldFirst];
g[x_?NumericQ]:=f[x]
Now use g[x] inside FindRoot.
David Bailey
http://www.dbaileyconsultancy.co.uk
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
ODE system - shooting for a terminal point The Mighty Algernon <joaopereira9@gmail.com> - 2011-08-31 10:08 +0000 Re: ODE system - shooting for a terminal point David Bailey <dave@removedbailey.co.uk> - 2011-09-02 07:31 +0000
csiph-web