In the Symbolic toolbox,how to get the results like in the old version

1 view (last 30 days)
In the symbolic toolbox, the results in newer version are different from the old version. For example:
>> syms x
>> int(1/(x-x^2))
In new version:
ans =
2*atanh(2*x - 1)
In old version:
ans=
log(x)-log(x-1)
______________________________________________
and:
>> dsolve('Dx=x-x^2')
In new version:
ans =
1
0
-1/(exp(C2 - t) - 1)
In old version:
ans=
1/(1+exp((-t)*C1)
________________________________________________
And also:
>> int(x-x^2)
In new version:
ans =
-(x^2*(2*x - 3))/6
>> pretty(ans)
2
x (2 x - 3)
>> collect(ans)
ans =
- x^3/3 + x^2/2
- ------------
6
In old version:
ans=
1/2*x^2-1/3*x^3
______________________________________________________-
There even a bigger difference:
>>syms a b c d x;
>>solve('a*x^3+b*x^2+c*x+d=0')
In Matlab(V6.5), x can be expressed by a,b,c,d though it is a long expression.
But in Matlab R2018, the result is as follow:
>>syms a b c d x
>>eqn=a*x^3+b*x^2+c*x+d==0
>> solve(eqn,x)
ans =
root(a*z^3 + b*z^2 + c*z + d, z, 1)
root(a*z^3 + b*z^2 + c*z + d, z, 2)
root(a*z^3 + b*z^2 + c*z + d, z, 3)
It did nothing indeed!
I want to have the results like the ones in the old version, what can I do?
Thanks in advance for the help!
  2 Comments
Walter Roberson
Walter Roberson on 23 Nov 2021
Note: in MATLAB 6.5, the symbolic toolbox was based around Maplesoft's Maple software; in current versions, it is based on the MuPAD symbolic engine.

Sign in to comment.

Accepted Answer

Paul
Paul on 22 Nov 2021
Edited: Paul on 22 Nov 2021
% first example
syms x
g(x) = 1/(x - x^2);
f(x) = int(g(x))
f(x) = 
simplify(rewrite(f(x),'log'),100)
ans = 
% as it turns out, f(x) returned by 2021b is the same as the "old
% solution." But this didn't have to be the case; they could have differed
% by a constant because this usage of int returns an anti-derivative.
% second example
clear
syms x(t)
sol = dsolve(diff(x(t))==x-x^2)
sol = 
% the second and third entries are valid solutions to the differential
% equation (for specific boundary condtions) as can be seen by direct subustitution.
% Don't know why the "old
% version" did not return these solutions. Also, we see that 2021b returns
% sol(1) in a different from than the "new version" in the Question. But
% it's the same answer as the old version
sol = sol(1);
[num,den] = numden(sol);
sol = 1/simplify(den/num)
sol = 
% but C1 is arbitrary, so we are allowed to negate it
syms C1
sol = subs(sol,C1,-C1)
sol = 
% we can also manipulate the expression in the Question
syms C2
g(t) = -1/(exp(C2 - t) - 1)
g(t) = 
g(t) = expand(g(t))
g(t) = 
% but C2 is an arbitrary constant, so we can sub it for a different
% arbitrary consant, which returns us to the form of sol given above.
g(t) = subs(g(t),exp(C2),C1)
g(t) = 
% third example
clear
syms x
f(x) = int(x-x^2)
f(x) = 
f(x) = expand(f(x))
f(x) = 
% Fourth example. Use the MaxDegree option
clear
syms a b c d x
eqn=a*x^3+b*x^2+c*x+d==0;
sol = solve(eqn,'MaxDegree',3)
sol = 

More Answers (1)

Yongjian Feng
Yongjian Feng on 22 Nov 2021
Seems like the same answer but presented in different form. The new version factorizes the result for example for
int(x-x^2)
It should not matter, right?

Community Treasure Hunt

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

Start Hunting!