Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: FindRoot with NDSolve inside of it doesn't work

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111358] Re: FindRoot with NDSolve inside of it doesn't work
  • From: Peter Breitfeld <phbrf at t-online.de>
  • Date: Wed, 28 Jul 2010 07:26:32 -0400 (EDT)
  • References: <i2ok79$7vf$1@smc.vnet.net>

Sam Takoy wrote:

> Hi,
>
> I think it's completely self-explanatory what I'm trying to do in this 
> model example:
>
> f[x0_, y0_] := (
>    sol = NDSolve[{x'[t] == x[t], y'[t] == y[t], x[0] == x0,
>       y[0] == y0}, {x, y}, {t, 0, 1}];
>    {x[1], y[1]} /. sol[[1]]
>    )
>
> (*f[x0_, y0_]:={x0 Exp[1], y0 Exp[1]}; (* Works for this f *) *)
> FindRoot[f[x0, y0] == {2.7, 5.4}, {{x0, 1}, {y0, 2}}]
>
> Can someone please help me fix this and explain why it's not currently 
> working?
>
> Many thanks in advance!
>
> Sam
>

You should force the parameters of to be numeric. This is often
helpful, when you get weird result with numeric functions. So write

Clear[f]
f[x0_?NumericQ, y0_?NumericQ]:=<your code from above>

You'll get without any warning:

Out= {x0->0.993274,y0->1.98655}

-- 
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de


  • Prev by Date: Re: Wire Frame Surface_Rainbow Colored
  • Next by Date: Re: Pochhammer Special Function
  • Previous by thread: FindRoot with NDSolve inside of it doesn't work
  • Next by thread: Re: FindRoot with NDSolve inside of it doesn't work