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

4 views (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:
>> dsolve('Dx=x-x^2')
In new version:
ans =
-1/(exp(C2 - t) - 1)
In old version:
And also:
>> int(x-x^2)
In new version:
ans =
-(x^2*(2*x - 3))/6
>> pretty(ans)
x (2 x - 3)
>> collect(ans)
ans =
- x^3/3 + x^2/2
- ------------
In old version:
There even a bigger difference:
>>syms a b c d x;
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
>> 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!

Sign in to comment.

Accepted Answer

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) = 
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
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
syms x
f(x) = int(x-x^2)
f(x) = 
f(x) = expand(f(x))
f(x) = 
% Fourth example. Use the MaxDegree option
syms a b c d x
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
It should not matter, right?

Community Treasure Hunt

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

Start Hunting!

Translated by