TomH
TomH

Reputation: 101

Force re-evaluation of maxima variable

This may be super simple but I cannot find a way to get Maxima to tell me that c is now 8, not 3? Can anyone help?

(%i1) a:1;
(%o1)                                  1
(%i2) b:2;
(%o2)                                  2
(%i3) c:a+b;
(%o3)                                  3
(%i4) ''c;
(%o4)                                  3
(%i5) a:6;
(%o5)                                  6
(%i6) ''c;
(%o6)                                  3

Many thanks Tom

Upvotes: 2

Views: 269

Answers (1)

Thor
Thor

Reputation: 47209

The easiest way is to define include a prevent evaluation (') operator in the definition ofc. For example:

(%i1) c : '(a+b);
(%o1)                                                       b + a
(%i2) a:1;
(%o2)                                                         1
(%i3) b:2;
(%o3)                                                         2
(%i4) ''c;
(%o4)                                                         3
(%i5) a:6;
(%o5)                                                         6
(%i6) ''c;
(%o6)                                                         8

Note that you can also post-fix the values of a and b:

(%i7) c, a:11, b:5;
(%o7)                                                         16

Upvotes: 2

Related Questions