Symbolic toolbox (Maple) - weird behavior

1 view (last 30 days)
I am using the Maple symbolic engine to evaluate the following expressions:
  1. expand(subs(int('(1-i+s*i+t*i)^p','s',0,1),'p',1))
  2. expand(subs(int('(1 -s*i+t*i)^p','s',0,1),'p',1))
The result should be exactly the same. However, the second one give the completely wrong result "1/2 i", which does not even depend on 't' as it should.
  • It is essential for my purposes to first integrate and only then substitute 'p'.
  • The same problem happens for any integer p>0 (not just p=1).
  • If I repeat the same experiment with 't' instead of 't*i' in the original expressions, everything calculates alright:
  1. expand(subs(int('(1-i+s*i+ t )^p','s',0,1),'p',1)) gives exactly the same result as
  2. expand(subs(int('(1 -s*i+ t )^p','s',0,1),'p',1))
Is this a bug? Any ideas?
[using Matlab 2011b and Maple 15.00 -- the problem occurs with newer versions as well...]
Thanks, Shahar.

Accepted Answer

Walter Roberson
Walter Roberson on 15 Mar 2012
My understand, perhaps incorrect, is that all support for Maple as the symbolic engine after R2010b was supplied by Maplesoft -- e.g., symengine cannot be set in current versions.
I confirm the integration oddity in Maple 15; later today I will test in a newer Maple version and will report a bug if it happens in that version as well.
I have a good idea of what the response will be probably be, though: that it is a boundary-condition issue. Definite integration works by extrapolating the function from s and s+deltas and taking the difference and working that back to expression form for the indefinite integral, and then substituting in the actual limits supplied; that algorithm is known to produce odd results when the behavior of the function changes significantly with increasing values.
  2 Comments
Walter Roberson
Walter Roberson on 15 Mar 2012
I have confirmed the problem in a newer Maple version, and have submitted a Maple bug report. I would not expect there to be a correction until at least Maple 17.
The work-around is to work at the Maple level and use Int() instead of int(), holding off evaluation of the integral as long as possible, and using value() against the Int() when it is time to get the result.
evalin(symengine, 'value(eval(Int((1-I*s+I*t)^p, s = 0 .. 1), p = 1))')
Shahar
Shahar on 18 Mar 2012
Walter, thank you very much for the quick answer.
I guess this means I can take a long nap until Maple 17 is released, right...? ;-)
Another possible work-around I saw is to first calculate the indefinite integral and then substitute the boundaries:
F=int('(1-s*i+t*i)^p','s'); expand(subs(subs(F,'s',1)-subs(F,'s',0),'p',1)).
However, since I don't really understand the origin of the problem, I'm not certain this always works okay either...
Please update if you get an interesting answer from Maple.
Thanks again,
Shahar.

Sign in to comment.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!