MathGroup Archive 1997

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

Search the Archive

Re: Help on FindRoot

  • To: mathgroup at
  • Subject: [mg5798] Re: [mg5786] Help on FindRoot
  • From: seanross at
  • Date: Wed, 22 Jan 1997 00:44:09 -0500
  • Sender: owner-wri-mathgroup at

Hossein Kazemi wrote:
> I have the following lines:
> h[0]=1;
> x[t_]:=2^h[t] - 3*h[t-1];
> Table[h[t]=h[t]/.FindRoot[x[t]==t,{h[t],2}],{t,1,5}]
> As you can see, I am trying to solve for different values of h[t], which
> is recursively depends on h[t-1].
> MMA (3.0) gives a bunch of errors such as
> Unset:: norep: Assignment on h for h[1] not found.
> and so on.
> However, it also gives the correct answers at the end.
> What is going on?  Am I doing something wrong?
> **********************************************************
> Hossein Kazemi
> University of Massachusetts

Your function definition is not truly recursive.  You define h[0], so 
when I call x[1], I need to know h[1] and h[0].  I would try re-defining 
the problem so that you used something like:

h[t]=z/.FindRoot[2^z -3 h[t-1]==t,{z,2}].  I have tested this code, but 
it seems like you are asking for a result before calculating it.  I 
would try and avoid doing root searches on the symbol h[t].

  • Prev by Date: Re: Help me please!!!
  • Next by Date: Re: Contour Plot
  • Previous by thread: Help on FindRoot
  • Next by thread: applying rule to one term??