MathGroup Archive 2008

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

Search the Archive

Re: Problems with FindRoot and recursive functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89683] Re: Problems with FindRoot and recursive functions
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 17 Jun 2008 00:40:52 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <g35g0m$9bv$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

try

x1[t_?NumericQ] := If[t < 0, {t, 1}, 0.5 + x1[t - 1]]

Regards
   Jens

Daniel Kuang Chen Liu wrote:
> Hello,
> 
> I have a recursive function of the form
> 
>>> x1[t_] := If[t < 0, {t, 1}, 0.5 + x1[t - 1]]
> 
> which returns a list of length 2, and the first element has a root at t=0.5
>>> In[3]:= x1[0.5]
>>> Out[3]= {0., 1.5}
> 
> I want to use FindRoot to determine t0 such that x1[t0][[1]] == 0, so I use
> the following code
> 
>>> FindRoot[x1[t][[1]] == 0, {t, 0.5}]
> 
> to which Mathematica complains
> 
> During evaluation of In[6]:= FindRoot::nlnum: The function value
> {False} is not a list of numbers with dimensions {1} at {t} = {0.5}.
> 
> It would much appreciated if someone could tell me what is wrong with the
> code.
> 
> Daniel Liu
> 
> 


  • Prev by Date: How to preserve a slider setting between notebook sessions?
  • Next by Date: Memory-mapped files
  • Previous by thread: Re: Problems with FindRoot and recursive functions
  • Next by thread: Re: Problems with FindRoot and recursive functions