Symbolic Integration Bug?

1 view (last 30 days)
Hi All,
Is this a bug of symbolic toolbox? It is kind of messing up when changing the signs.
clear all; clc;
syms x L1 L2;
L1val = 10;
L2val = 20;
Ma = -(x-L1)^2;
Mb = -(x^2+L1^2-2*x*L1);
Maint = int(Ma, x);
Mbint = int(Mb, x);
vpa(subs(subs(Maint, L1, L1val),x, 1))
vpa(subs(subs(Mbint, L1, L1val),x, 1))
ans =
ans =

Accepted Answer

Walter Roberson
Walter Roberson on 3 May 2019
No bug. You are doing indefinite integration, which is permitted to have a constant of integration. You are evaluating at a single point rather than evaluating the difference between two locations, so the constant of integration is included in the value. It is permitted for the two forms to generate two different constants of integration.
If you were to
syms a
Maint = int(Ma, x, a, x);
Mbint = int(Mb, x, a, x);
then you would get the same result for the two.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!