Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with recursive assignment

108 views
Skip to first unread message

Gerard

unread,
Nov 23, 2006, 3:08:57 PM11/23/06
to
Maple 9.3:

When I try
> x := x[0] + t^2;
I get "Error, recusive assignment", but when I try
> x := t -> x[0] + t^2;
x(t);
x(0);
I get the outputs
x := t -> x_0 + t^2
x_0 + t^2
x_0

So the latter method doesn't mind the possible recursion.
But it also does not give me what I want. Is there some way
to force maple to create a variable x that has x[0] in its value?

I could of course use x0 in stead of x[0] but that is not what
we want.

I already tried subs, but that did not work either:
> x := k + t^2;
subs( k=x[0], x );
produces
x := k + t^2
(k+t^2)_0 + t^2

HELP!

TIA and regards,
G.


A N Niel

unread,
Nov 23, 2006, 6:24:21 PM11/23/06
to
In article <ek4v51$igt$1...@aioe.server.aioe.org>, Gerard
<no....@no.where> wrote:

> > x := x[0] + t^2;


So this would mean
x[0] + t^2 = (x[0] + t^2)[0] + t^2
= ((x[0] + t^2)[0] + t^2)[0] + t^2
and so on.

If that is really what you want, then Maple cannot do this.

If it is NOT what you want, you need to explain...

Robert Israel

unread,
Nov 23, 2006, 8:24:26 PM11/23/06
to
In article <ek4v51$igt$1...@aioe.server.aioe.org>,
Gerard <no....@no.where> wrote:
>Maple 9.3:
>
>When I try
> > x := x[0] + t^2;
>I get "Error, recusive assignment", but when I try
> > x := t -> x[0] + t^2;
> x(t);
> x(0);
>I get the outputs
> x := t -> x_0 + t^2
> x_0 + t^2
> x_0
>
>So the latter method doesn't mind the possible recursion.
>But it also does not give me what I want. Is there some way
>to force maple to create a variable x that has x[0] in its value?

Actually, I suspect you want a variable x that has something that
_looks_ like x_0 as its value. Try

> x:= `tools/rename`(x)[0];

Robert Israel isr...@math.ubc.ca
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia Vancouver, BC, Canada

Gerard

unread,
Nov 24, 2006, 12:19:10 PM11/24/06
to

"Robert Israel" <isr...@math.ubc.ca> wrote in message news:ek5hka$3t6$1...@nntp.itservices.ubc.ca...

> In article <ek4v51$igt$1...@aioe.server.aioe.org>,
> Gerard <no....@no.where> wrote:
>>Maple 9.3:
>>
>>When I try
>> > x := x[0] + t^2;
>>I get "Error, recusive assignment", but when I try
>> > x := t -> x[0] + t^2;
>> x(t);
>> x(0);
>>I get the outputs
>> x := t -> x_0 + t^2
>> x_0 + t^2
>> x_0
>>
>>So the latter method doesn't mind the possible recursion.
>>But it also does not give me what I want. Is there some way
>>to force maple to create a variable x that has x[0] in its value?
>
> Actually, I suspect you want a variable x that has something that
> _looks_ like x_0 as its value. Try
>
> > x:= `tools/rename`(x)[0];

You probably mean
> x0 := `tools/rename`(x)[0];
which gives the correct output.
Also the definition
> x := x0 + t^2
gives
x := x_0 + t^2 (with subscript)
which looks okay.

But it is not really okay. There seems to be no way to give x[0] a
value now.
When I try
> x[0] := 3; t := 6; x;
I get the output
x_0 := 3 (with subscript, of course)
t := 6
x (the x I just defined is dead)

So I can't use this.

It looks like Maple does not treat an indexed name like x[0] on an
equal footing as the names x and x0. It is clear that x and x0 are
fully independent variables, but x[0] is something that cannot really
be used as a variable - unless you take care never to use x as
a variable in the same context.
Indeed, I just tried this:
> restart;
> x := t^2;
x := t^2
> x;
t^2
> x[1] := 12;
x_1 := 12
> x;
x (dead)

We have to create an HTML formatted article with proper subscript
notation, like x_0 ("x subscript 0") as opposed to the ugly x0.
This is just one example. The article has many functions (f) and
subscripted variables (f_i).
It seems we won't be able to use Maple for this.
Or does someone know a secret workaround?

Thanks,
G.


Gerard

unread,
Nov 24, 2006, 12:21:02 PM11/24/06
to

"A N Niel" <ann...@nym.alias.net.invalid> wrote in message news:231120061824215313%ann...@nym.alias.net.invalid...

It is not what I want.
I explained in my answer to Robert Israel.
Thanks and regards,
G.


Walter Roberson

unread,
Nov 24, 2006, 12:52:31 PM11/24/06
to
In article <ek79io$lsg$1...@aioe.server.aioe.org>,

Gerard <no....@no.where> wrote:
>You probably mean
> > x0 := `tools/rename`(x)[0];
>which gives the correct output.
>Also the definition
> > x := x0 + t^2
>gives
> x := x_0 + t^2 (with subscript)
>which looks okay.

>But it is not really okay. There seems to be no way to give x[0] a
>value now.
>When I try
> > x[0] := 3; t := 6; x;
>I get the output
> x_0 := 3 (with subscript, of course)
> t := 6
> x (the x I just defined is dead)

>So I can't use this.

x0 := `tools/rename`('x')[0];
x := x0 + 't'^2;
assign(eval(x0,1),3);
t := 6;
x;
assign(eval(x0,1),7);
t := 11;
x;
eval(x,1);
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson

Walter Roberson

unread,
Nov 24, 2006, 12:58:00 PM11/24/06
to
In article <ek7bgv$7jr$1...@canopus.cc.umanitoba.ca>,

Walter Roberson <robe...@ibd.nrc-cnrc.gc.ca> wrote:
>In article <ek79io$lsg$1...@aioe.server.aioe.org>,
>Gerard <no....@no.where> wrote:

>> x := x_0 + t^2 (with subscript)

>x0 := `tools/rename`('x')[0];


>x := x0 + 't'^2;
>assign(eval(x0,1),3);
>t := 6;
>x;
>assign(eval(x0,1),7);
>t := 11;
>x;
>eval(x,1);

More simply,

x := `x[0]` + t^2;
`x[0]` := 3;
t := 6;
x;
`x[0]` := 7;


t := 11;
x;
eval(x,1);

--
"It is important to remember that when it comes to law, computers
never make copies, only human beings make copies. Computers are given
commands, not permission. Only people can be given permission."
-- Brad Templeton

Gerard

unread,
Nov 24, 2006, 1:24:25 PM11/24/06
to

"Walter Roberson" <robe...@ibd.nrc-cnrc.gc.ca> wrote in message news:ek7bgv$7jr$1...@canopus.cc.umanitoba.ca...

SUPER! That makes two syllables, right?

I have tested this out on the entire project and it does exactly
what we want it to do!

Thanks a big bunch and kind regards,
G.


isr...@math.ubc.ca

unread,
Nov 24, 2006, 2:07:22 PM11/24/06
to

You could do that if you saved the "new" x under a different name.

> newx:= `tools/rename`(x);
x:= newx[0] + t^2;
assign(newx[0], 6);
x;

> It looks like Maple does not treat an indexed name like x[0] on an
> equal footing as the names x and x0. It is clear that x and x0 are
> fully independent variables, but x[0] is something that cannot really
> be used as a variable - unless you take care never to use x as
> a variable in the same context.
> Indeed, I just tried this:
> > restart;
> > x := t^2;
> x := t^2
> > x;
> t^2
> > x[1] := 12;
> x_1 := 12
> > x;
> x (dead)

When you assign a value to x[1], you implicitly make x into a table
whose entry for
index 1 is that value. If it's a table, it can't have the value t^2.
That's why you need
a different name.

Gerard

unread,
Nov 24, 2006, 2:56:25 PM11/24/06
to

"Walter Roberson" <robe...@ibd.nrc-cnrc.gc.ca> wrote in message news:ek7br8$829$1...@canopus.cc.umanitoba.ca...

> In article <ek7bgv$7jr$1...@canopus.cc.umanitoba.ca>,
> Walter Roberson <robe...@ibd.nrc-cnrc.gc.ca> wrote:
>>In article <ek79io$lsg$1...@aioe.server.aioe.org>,
>>Gerard <no....@no.where> wrote:
>
>>> x := x_0 + t^2 (with subscript)
>
>>x0 := `tools/rename`('x')[0];
>>x := x0 + 't'^2;
>>assign(eval(x0,1),3);
>>t := 6;
>>x;
>>assign(eval(x0,1),7);
>>t := 11;
>>x;
>>eval(x,1);
>
> More simply,
>
> x := `x[0]` + t^2;
> `x[0]` := 3;
> t := 6;
> x;
> `x[0]` := 7;
> t := 11;
> x;
> eval(x,1);

Yes, but this way there are no subscripts in the output, and
subscripted indices is what we absolutely need.

Thanks again,
G.


Gerard

unread,
Nov 24, 2006, 3:03:29 PM11/24/06
to

<isr...@math.ubc.ca> wrote in message news:1164395242.0...@l12g2000cwl.googlegroups.com...

Yes, this is similar to Walter Roberson's workaround.

>> It looks like Maple does not treat an indexed name like x[0] on an
>> equal footing as the names x and x0. It is clear that x and x0 are
>> fully independent variables, but x[0] is something that cannot really
>> be used as a variable - unless you take care never to use x as
>> a variable in the same context.
>> Indeed, I just tried this:
>> > restart;
>> > x := t^2;
>> x := t^2
>> > x;
>> t^2
>> > x[1] := 12;
>> x_1 := 12
>> > x;
>> x (dead)
>
> When you assign a value to x[1], you implicitly make x into a table
> whose entry for
> index 1 is that value. If it's a table, it can't have the value t^2.
> That's why you need
> a different name.

I understand now.
I think we can work things out now.

Thanks (a lot!) again and regards,
G.


0 new messages