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.
> > 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...
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
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.
It is not what I want.
I explained in my answer to Robert Israel.
Thanks and regards,
G.
>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
>> 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
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.
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.
Yes, but this way there are no subscripts in the output, and
subscripted indices is what we absolutely need.
Thanks again,
G.
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.