I’ve observed a strange sign bug in student[changevar] ; look at this small session with Maple output:
> integral := Int(1, x=1..2) ; integral := Int(1,x = 1 .. 2) > value(%) ; 1 > with(student, changevar) ; [changevar] > changevar(t=1-1/sqrt(x), integral, t) ; Int(2/(-1+t)^3,t = 0 .. 1/2*(2^(1/2)-1)*2^(1/2)) > value(%) ; -1
Computing by hand, it is clear the right integrand after changevar should be -2/(-1+t)^3
:
Probably this type of error had already been noted ? Is there some "philosophical" idea which could alert the user about such a possible error ? In the above changevar, the traditional difficulty where the variable change reverses the orientation does not occur, so that I don’t understand what the origin of this sign bug could be.
It’s not a bug, there are two possible branches. If you substitute \(x = 1/(t-1)^2\) the other branch is used.
The reason for the result is the solution of the equation \(x = 1/(t-1)^2\) for \(t\) to calculate the limits of integration. (U. Klein)
That’s an interesting bug. The culprit is the square root function. A possible solution is
that you don’t use an equation like t=1-1/sqrt(x) but solve it for x yourself before
changing variables:
> restart; > with(student): > integral:=Int(1,x=1..2); > x=solve(t=1-1/sqrt(x),x); > changevar(%,integral,t); > value(%); 1
Although ‘student/changevar‘() at some point solves the equation ’substitut’ for x it does not use that result when computing the new integrand.
If there is a square root in ’substitut’ then this is a difficult approach:
> subs(x=x(t),substitut); > map(diff,%,t); > solve(%,diff(x(t),t)); > subs(x(t)=x,%); > jj:=eval(subs(r,%)); / 1 \(3/2) jj := 2 |---------| | 2| \(-1 + t) /
Now ‘student/changevar‘() uses ‘expand/radical‘, which simplifies jj incorrectly:
‘student/changevar‘() should analyze the value of t for x=1..2 and notice that t would always be less than 1:
Then jj could be simplified correctly:
> simplify(jj,assume=real); > applyop( > u->simplify(subs(t=1-tau,u),assume=positive), 2, % > ); > jnew:=subs(r,j)*%; 1 jnew := -2 --------- 3 (-1 + t)
IMO the following would be much easier for ‘student/changevar‘() to execute: