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

조회 수: 4 (최근 30일)
Xizeng Feng . 2021년 11월 22일
댓글: Xizeng Feng . 2021년 11월 23일
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표시 이전 댓글 수: 1숨기기 이전 댓글 수: 1
Xizeng Feng 2021년 11월 23일
thank you for the reminding!

댓글을 달려면 로그인하십시오.

### 채택된 답변

Paul 2021년 11월 22일
편집: Paul 님. 2021년 11월 22일
% 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 = ##### 댓글 수: 1표시 없음숨기기 없음
Xizeng Feng 2021년 11월 23일

댓글을 달려면 로그인하십시오.

### 추가 답변 (1개)

Yongjian Feng 2021년 11월 22일
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?

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!