MathGroup Archive 2008

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

Search the Archive

Re: FindROot and substitutions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89851] Re: FindROot and substitutions
  • From: magma <maderri2 at gmail.com>
  • Date: Sun, 22 Jun 2008 03:26:12 -0400 (EDT)
  • References: <g3ihp3$fd5$1@smc.vnet.net>

On Jun 21, 11:31 am, Aaron Fude <aaronf... at gmail.com> wrote:
> Hi,
>
> I have found a workaround for this problem, but I would like to
> understand how Mathematica wants you to think so I'm asking the
> question anyway.
>
> Why does "bad" not work, while "good" works?
>
> g := x z;
> bad[z_] := FindRoot[ g == 5, {x, -10, 10 }];
> bad[5]
> good[k_] := FindRoot[ g == 5 /. z -> k, {x, -10, 10 }];
> good[6]
>
> Thanks!
>
> Aaron

If you execute

On[]
bad[5]
Off[]

you can solve the arcane.
You get a lengthy output, but from the very first lines you can
clearly see that g gets replaced by x z, but z never gets replaced by
5.
So FindRoot starts looking for solutions of x z == 5, which is a
symbolic equation (z is a symbol) and cannot be "Findroot-ed".

This is a working code:

gg[z_] := x z
notsobad[z_] := FindRoot[gg[z] == 5, {x, -10, 10}]

and now...

notsobad[5]

works as desired
In other words: you should make explicit in g (or gg)  the z
dependence.


  • Prev by Date: Re: FindROot and substitutions
  • Next by Date: Re: FindROot and substitutions
  • Previous by thread: Re: FindROot and substitutions
  • Next by thread: Re: FindROot and substitutions