# symbolic integration depends on different equivalent forms of function

1 view (last 30 days)
Michal on 15 Jul 2022
Commented: Michal on 17 Jul 2022
I performed the following equaivalent symbolic integrations:
syms x y
A = int(x+y,x);
A_ = expand(A); % just expanded (equaivalent) form of A
B = expand(int(A,y))
B_ = expand(int(A_,y))
with the following results:
A =
(x*(x + 2*y))/2
A_ =
x^2/2 + y*x
B =
x^3/8 + (x^2*y)/2 + (x*y^2)/2
B_ =
(x^2*y)/2 + (x*y^2)/2
I expect B equal to B_, but there is a misterious additional term x^3/8 at B ??!!
Is that a bug???

Torsten on 15 Jul 2022
The difference is a usual "constant of integration".
If you differentiate both B and B_ with respect to y and then with respect to x, you'll arrive at the expression x+y in both cases:
syms x y
B_ = (x^2*y)/2 + (x*y^2)/2;
B = x^3/8 + (x^2*y)/2 + (x*y^2)/2;
A_ = diff(B_,y);
A = diff(B,y);
expr1 = diff(A_,x)
expr1 =
expr2 = diff(A,x)
expr2 =
Paul on 15 Jul 2022
Edited: Paul on 15 Jul 2022
I'm not surprised either. I've seen cases where int() couldn't find a solution unless the integrand was manipulated using simplify, expand, etc. Here is an example from this Question
syms t
assume(t, "real")
f1 = 3*t-t*t*t;
f2 = 3*t*t;
f = [f1, f2];
df = diff(f, t);
a = 0;
b = 1;
normDf = sqrt(df(1)*df(1)+df(2)*df(2));
int(normDf,t,a,b) % no solution
ans =
normDf = simplify(normDf)
normDf =
int(normDf, t, a, b) % easy
ans =
4

Michal on 16 Jul 2022
Edited: Michal on 16 Jul 2022
Simple solution to avoid integration constant effect:
int(f(x),x,0,x)
Michal on 17 Jul 2022
Well... You are right!

### Categories

Find more on Numbers and Precision in Help Center and File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by