expanded vs unexpanded polynomials in symbolic integrals
28 views (last 30 days)
Show older comments
I was doing some simple kinematics equations in matlab and I was getting the wrong answer for a long time until I expanded my function before integration using expand(). Is there a reason for this?
This was my orginial code which outputs position as 144.3144 meters
time = 2; %sec
m = 0.183; %kg
g = 9.81; %m/s^2
syms t
T = 15 - 15 * (t-1)^2; %N
aT = T/m;
a = aT - g;
v = int(a);
x = int(v);
position = double(subs(x,t,time))
This is the code I ended up using with the added expand() function which outputs position as 89.6696 meters
time = 2; %sec
m = 0.183; %kg
g = 9.81; %m/s^2
syms t
T = 15 - 15 * expand((t-1)^2); %N
aT = T/m;
a = aT - g;
v = int(a);
x = int(v);
position = double(subs(x,t,time))
0 Comments
Accepted Answer
Torsten
on 10 Dec 2025 at 20:43
Edited: Torsten
on 10 Dec 2025 at 20:55
Without giving the limits of integration, "int" returns an arbitrary antiderivative for the function you want to integrate. But you want a special one in your application.
time = 2; %sec
m = 0.183; %kg
g = 9.81; %m/s^2
syms t
T = 15 - 15 * (t-1)^2; %N
aT = T/m;
a = aT - g;
v = int(a,0,t);
x = int(v,0,t);
position = double(subs(x,t,time))
time = 2; %sec
m = 0.183; %kg
g = 9.81; %m/s^2
syms t
T = 15 - 15 * expand((t-1)^2); %N
aT = T/m;
a = aT - g;
v = int(a,0,t);
x = int(v,0,t);
position = double(subs(x,t,time))
Maybe even these results for position are wrong because they implicitly assume that you want x(0) = v(0) = 0.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!