Matlab ilaplace not working properly

47 views (last 30 days)
Antonio Olinto Tonisi
Antonio Olinto Tonisi on 24 Nov 2024 at 3:11
Edited: Walter Roberson on 25 Nov 2024 at 3:56
How can I make matlab return the answer directly and automaticaly?
ilaplace(40/(s*(2*s^3 + s^2 + 6*s + 2)))
% matlab just answers 20 - 40*symsum((exp(t*root(s3^3 + s3^2/2 + 3*s3 + 1, s3, k))*root(s3^3 + s3^2/2 + 3*s3 + 1, s3, k)^2)/(2*(root(s3^3 + s3^2/2 + 3*s3 + 1, s3, k) + 3*root(s3^3 + s3^2/2 + 3*s3 + 1, s3, k)^2 + 3)), k, 1, 3) - 120*symsum(exp(t*root(s3^3 + s3^2/2 + 3*s3 + 1, s3, k))/(2*(root(s3^3 + s3^2/2 + 3*s3 + 1, s3, k) + 3*root(s3^3 + s3^2/2 + 3*s3 + 1, s3, k)^2 + 3)), k, 1, 3) - 20*symsum((exp(root(s3^3 + s3^2/2 + 3*s3 + 1, s3, k)*t)*root(s3^3 + s3^2/2 + 3*s3 + 1, s3, k))/(2*(root(s3^3 + s3^2/2 + 3*s3 + 1, s3, k) + 3*root(s3^3 + s3^2/2 + 3*s3 + 1, s3, k)^2 + 3)), k, 1, 3)

Accepted Answer

Paul
Paul on 24 Nov 2024 at 20:40
Edited: Paul on 24 Nov 2024 at 20:41
ilaplace can return a closed form, symbolic expression if we give it some help, though it's a bit of a mess. Unclear why it needs such help
syms s
syms t real
F(s) = (40/(s*(2*s^3 + s^2 + 6*s + 2)));
[num,den] = numden(simplify(F(s)));
num,den
num = num/2; den = den/2;
P = solve(den,'MaxDegree',3),disp(char(P))
[0; ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) - 35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - 1/6; 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - (3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 - 1/6; (3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 - 1/6]
f(t) = ilaplace(num/prod(s-P));
f(t) = simplify(real(rewrite(f(t),'sincos'))),disp(char(f(t)))
2*cos((3^(1/2)*5^(1/3)*t*((6*51^(1/2) - 11)^(1/3) + (6*51^(1/2) + 11)^(1/3)))/12)*exp(-t*((5^(1/3)*(6*51^(1/2) - 11)^(1/3))/12 - (5^(1/3)*(6*51^(1/2) + 11)^(1/3))/12 + 1/6))*((71*5^(2/3)*(6*51^(1/2) - 11)^(2/3))/735 - (5^(1/3)*(6*51^(1/2) - 11)^(1/3))/21 + (9*5^(1/3)*51^(1/2)*(6*51^(1/2) - 11)^(1/3))/119 + (19*5^(2/3)*51^(1/2)*(6*51^(1/2) - 11)^(2/3))/4165 - 20/3) - exp(-t*((5^(1/3)*(6*51^(1/2) + 11)^(1/3))/6 - (5^(1/3)*(6*51^(1/2) - 11)^(1/3))/6 + 1/6))*((190*5^(1/3)*(4718473 - 516648*51^(1/2))^(1/3))/7203 + (3614*5^(2/3)*(33993966*51^(1/2) - 209997491)^(1/3))/1260525 + (26*5^(1/3)*51^(1/2)*(4718473 - 516648*51^(1/2))^(1/3))/40817 + (5246*5^(2/3)*51^(1/2)*(33993966*51^(1/2) - 209997491)^(1/3))/7142975 + 20/3) - (2*5^(1/3)*sin((3^(1/2)*5^(1/3)*t*((6*51^(1/2) - 11)^(1/3) + (6*51^(1/2) + 11)^(1/3)))/12)*exp(-t*((5^(1/3)*(6*51^(1/2) - 11)^(1/3))/12 - (5^(1/3)*(6*51^(1/2) + 11)^(1/3))/12 + 1/6))*(35*(6*51^(1/2) - 11)^(1/3)*(17*3^(1/2) - 81*17^(1/2)) + 1207*3^(1/2)*5^(1/3)*(6*51^(1/2) - 11)^(2/3) + 171*5^(1/3)*17^(1/2)*(6*51^(1/2) - 11)^(2/3)))/12495 + 20
vpa(f(t),2),disp(char(ans))
20.0 - 0.4*exp(-0.08*t)*cos(1.7*t) - 3.9*exp(-0.08*t)*sin(1.7*t) - 20.0*exp(-0.34*t)
figure
fplot(f(t),[0 100]),grid

More Answers (1)

Walter Roberson
Walter Roberson on 25 Nov 2024 at 3:55
Edited: Walter Roberson on 25 Nov 2024 at 3:56
syms s
sol = ilaplace(40/(s*(2*s^3 + s^2 + 6*s + 2)))
disp(char(sol))
20 - 120*symsum(exp(t*root(z^3 + z^2/2 + 3*z + 1, z, k))/(2*(root(z^3 + z^2/2 + 3*z + 1, z, k) + 3*root(z^3 + z^2/2 + 3*z + 1, z, k)^2 + 3)), k, 1, 3) - 20*symsum((exp(root(z^3 + z^2/2 + 3*z + 1, z, k)*t)*root(z^3 + z^2/2 + 3*z + 1, z, k))/(2*(root(z^3 + z^2/2 + 3*z + 1, z, k) + 3*root(z^3 + z^2/2 + 3*z + 1, z, k)^2 + 3)), k, 1, 3) - 40*symsum((exp(t*root(z^3 + z^2/2 + 3*z + 1, z, k))*root(z^3 + z^2/2 + 3*z + 1, z, k)^2)/(2*(root(z^3 + z^2/2 + 3*z + 1, z, k) + 3*root(z^3 + z^2/2 + 3*z + 1, z, k)^2 + 3)), k, 1, 3)
fullsol = rewrite(rewrite(sol, 'expandsum'), 'expandroot')
disp(char(fullsol))
(10*exp(-t*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) + 1/6))*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) + 1/6))/(3*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) + 1/6)^2 - 35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) + 17/6) - (60*exp(t*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 - 1/6)))/((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 3*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 - 1/6)^2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 17/6) - (60*exp(-t*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 - 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 1/6)))/(3*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 - 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 1/6)^2 - (3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 17/6) - (20*exp(-t*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) + 1/6))*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) + 1/6)^2)/(3*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) + 1/6)^2 - 35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) + 17/6) - (20*exp(t*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 - 1/6))*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 - 1/6)^2)/((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 3*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 - 1/6)^2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 17/6) - (20*exp(-t*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 - 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 1/6))*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 - 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 1/6)^2)/(3*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 - 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 1/6)^2 - (3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 17/6) - (60*exp(-t*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) + 1/6)))/(3*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) + 1/6)^2 - 35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3) + 17/6) - (10*exp(t*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 - 1/6))*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 - 1/6))/((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 3*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 - 1/6)^2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 17/6) + (10*exp(-t*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 - 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 1/6))*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 - 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 1/6))/(3*((3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 - 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 1/6)^2 - (3^(1/2)*(35/(36*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) + ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3))*1i)/2 + 35/(72*((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)) - ((425^(1/2)*432^(1/2))/432 - 55/216)^(1/3)/2 + 17/6) + 20
You can simplify() this, but to be honest the result is more messy.

Community Treasure Hunt

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

Start Hunting!