Integration function generates different result by a same expression

A same expression in two style will be integrated in two different results, why ? and which result is correct ?
syms a b c x
y1=a*x+1+a*(b-c);
y2=1+a*(x+b-c);
>> int(y1)
ans =
(a*x^2)/2 + (a*(b - c) + 1)*x
>> int(y2)
ans =
x + (a*(b - c + x)^2)/2
and obviously they are not equal.
>> expand(int(y1))-expand(int(y2))
ans =
a*b*c - (a*c^2)/2 - (a*b^2)/2

 채택된 답변

Mischa Kim
Mischa Kim 2014년 2월 14일
편집: Mischa Kim 2014년 2월 14일
Tiger, this is because these are indefinite integrals. Solutions to indefinite integrals can differ by a constant. If you make them definite integrals by specifying integration limits, you will get the same answer. Something you can check with isequal, which will return 1 , for true. Or simply compute the difference.
int1 = int(y1,x,0,1);
int2 = int(y2,x,0,1);
isequal(int1,int2)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2014년 2월 14일

편집:

2014년 2월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by