Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5823 > unrolled thread

Re: A basic question about RecurrenceTable - warning messages

Started byDana DeLouis <dana01@me.com>
First post2011-10-23 10:34 +0000
Last post2011-10-25 10:19 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: A basic question about RecurrenceTable - warning messages Dana DeLouis <dana01@me.com> - 2011-10-23 10:34 +0000
    Re: A basic question about RecurrenceTable - warning messages victorphy <vbapst@gmail.com> - 2011-10-25 10:19 +0000

#5823 — Re: A basic question about RecurrenceTable - warning messages

FromDana DeLouis <dana01@me.com>
Date2011-10-23 10:34 +0000
SubjectRe: A basic question about RecurrenceTable - warning messages
Message-ID<j80qk9$ag5$1@smc.vnet.net>
Hi.  I see you found a solution.

f[x_,a_]:=-(x-a)^3+(x-a)

soltest[a_?NumericQ,b_?NumericQ]:=x/.FindRoot[f[x,a],{x,b}]

eqns =
 {a[n+1]==soltest[n/10,a[n]],
  a[0]==-1};

RecurrenceTable[eqns, a, {n,10}]  
{-1,-1.,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1}

I may be wrong, but I noticed you have two -1's in the beginning.
In the Recurrence table, n goes from 1 to 10.
However, there is no a[n-1] to refer to your initial a[0] = -1.
Again, I may be wrong, but I -think- it should be  a[1]== -1.

If we did that, then...

eqns =
 {a[n+1]==soltest[n/10,a[n]],
 a[1]==-1};

RecurrenceTable[eqns,a,{n,10}]  
{-1,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1}

If we take your initial equation, and substitute z for (x-a), then we get:

-(x-a)^3+(x-a)    //.(x-a)->z
z-z^3

We Factor to get the 3 solution for the zero function:

Factor[%]
-(-1+z) z (1+z)

I believe you are using FindRoot to solve for the 3rd equation (1+z).
If we substitute back in:

(1+z)/.z -> x-a
1-a+x

And solve for x.  Basically we get that x is a - 1.

Solve[%==0,x]
{{x-> a - 1}}

So, at 0, we have -1, and then as your numbers increase linearly...

Range[0,9]/10.   - 1

{-1.,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1}

Again, I may be wrong.  :>(

= = = = = = = = =
Dana DeLouis
$Version
"8.0 for Mac OS X x86 (64-bit) (February 23, 2011)"

- To understand recurrence, one must first understand recurrence.
= = = = = = =


On Oct 21, 7:30 am, victorphy <vba...@gmail.com> wrote:
> Hello,
> 
> I have a small and basic question about RecurrenceTable.
> 
> I would like to solve f(x,a)==0 where x is the unknown and a is a
> parameter. As f has several zeros I want to follow one zero when
> varying a.
> 
> Thus I write something like that :
> 
> f[x_,a_] :=  -(x - a)^3 + (x - a)
> 
> soltest[a_, b_] :=  x /. FindRoot[f[x, a], {x, b}]
> 
> RecurrenceTable[{a[n + 1] == soltest[n/10, a[n]], a[0] == -1}, a, {n,
> 10}]
> 
> I get the correct output but a lot of warning messages :
> 
> FindRoot::srect: "Value a[n] in search specification {x,a[n]} is not a
> number or array of numbers
> ReplaceAll::reps: "{FindRoot[f[x,n/10],{x,a[n]}]} is neither a list of
> replacement rules nor a valid dispatch table, and so cannot be used
> for replacing
> 
> Is there something that I am doing wrong ? Or is it just normal ?
> 
> Thank you very much for your answers.
> 
> Victor

[toc] | [next] | [standalone]


#5864

Fromvictorphy <vbapst@gmail.com>
Date2011-10-25 10:19 +0000
Message-ID<j862f1$5qb$1@smc.vnet.net>
In reply to#5823
On 23 oct, 12:34, Dana DeLouis <dan...@me.com> wrote:
> Hi.  I see you found a solution.
>
> f[x_,a_]:=-(x-a)^3+(x-a)
>
> soltest[a_?NumericQ,b_?NumericQ]:=x/.FindRoot[f[x,a],{x,b}]
>
> eqns =
>  {a[n+1]==soltest[n/10,a[n]],
>   a[0]==-1};
>
> RecurrenceTable[eqns, a, {n,10}]  
> {-1,-1.,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1}
>
> I may be wrong, but I noticed you have two -1's in the beginning.
> In the Recurrence table, n goes from 1 to 10.
> However, there is no a[n-1] to refer to your initial a[0] = -1.
> Again, I may be wrong, but I -think- it should be  a[1]== -1.
>
> If we did that, then...
>
> eqns =
>  {a[n+1]==soltest[n/10,a[n]],
>  a[1]==-1};
>
> RecurrenceTable[eqns,a,{n,10}]  
> {-1,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1}
>
> If we take your initial equation, and substitute z for (x-a), then we get:
>
> -(x-a)^3+(x-a)    //.(x-a)->z
> z-z^3
>
> We Factor to get the 3 solution for the zero function:
>
> Factor[%]
> -(-1+z) z (1+z)
>
> I believe you are using FindRoot to solve for the 3rd equation (1+z).
> If we substitute back in:
>
> (1+z)/.z -> x-a
> 1-a+x
>
> And solve for x.  Basically we get that x is a - 1.
>
> Solve[%==0,x]
> {{x-> a - 1}}
>
> So, at 0, we have -1, and then as your numbers increase linearly...
>
> Range[0,9]/10.   - 1
>
> {-1.,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1}
>
> Again, I may be wrong.  :>(
>


Hello Dana,

thank you for your detailled answer. As a matter of fact this was just
a silly example to test things and explain my problem !
But thank you for the advices you gave me anyway !

Best regards,

victor

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web