Greetings,
I'm trying to use the substitute
algorithm to set the value of a scalar expression but I'm getting some very odd results. In the following examples I set a variable s
to be 1 and the expected result should be zero. But in the first case I get 2. This problem only seems to arise for the single choice of s=1
.
Cheers, Leo
# ----------------------------------------------------
# fails, should return 0
foo := s - s**3;
substitute (foo, $s = 1$);
# ----------------------------------------------------
# success
foo := s - s*s*s;
substitute (foo, $s = 1$);
# ----------------------------------------------------
# success
foo := s**3 - s;
substitute (foo, $s = 1$);
# ----------------------------------------------------
# success
foo := s - s**3;
substitute (foo, $s = 2$);
# ----------------------------------------------------
# success
foo := s - s**3;
substitute (foo, $s = 1/2$);