My output is displayed as an unsolved form of the answer.

Hello I am trying to solve a question using a symbolic substitution, the code runs but the answers displayed are the unsolved form of the answer. Appreciate any help that i could get!
Thank you in advance!

2 Comments

syms rh wD t th xi w
v = rh * cos(wD*t + th) * exp(-xi*w*t);
dv_dt = diff(v,t);
d2v_dt2 = diff(dv_dt,t);
%Given:
s.m = 2;
s.k = 40;
s.v0 = 0.7;
s.vdot0 = 5.6;
s.c = 2.8;
s.t =1;
s.w = sqrt(s.k/s.m);
s.xi = s.c/(2*s.m*s.w);
s.wD = s.w*sqrt(1-s.xi^2);
s.rho = (s.v0^2 + ((s.vdot0 + s.v0*s.xi*s.w)/s.wD)^2)^(1/2);
s.theta = -atan((s.vdot0 + s.v0*s.xi*s.w)/(s.wD*s.v0));
Displacement = subs(v, {rh,wD,t,th,xi,w,t}, {s.rho,s.wD,s.t,s.theta,s.xi,s.w,s.t});
Velocity = subs(dv_dt, {rh,wD,t,th,xi,w,t}, {s.rho,s.wD,s.t,s.theta,s.xi,s.w,s.t});
Acceleration = subs(d2v_dt2,{rh,wD,t,th,xi,w,t}, {s.rho,s.wD,s.t,s.theta,s.xi,s.w,s.t});
format shortEng
format compact
Displacement
Velocity
Acceleration
The results are displayed as the following:
Displacement =
(14*119^(1/2)*9755^(1/2)*exp(-7/10)*cos(1951^(1/2)/10 - 4958488623312519/4503599627370496))/9755
Velocity =
- (49*119^(1/2)*9755^(1/2)*exp(-7/10)*cos(1951^(1/2)/10 - 4958488623312519/4503599627370496))/48775 - (7*119^(1/2)*1951^(1/2)*9755^(1/2)*exp(-7/10)*sin(1951^(1/2)/10 - 4958488623312519/4503599627370496))/48775
Acceleration =
(49*119^(1/2)*1951^(1/2)*9755^(1/2)*exp(-7/10)*sin(1951^(1/2)/10 - 4958488623312519/4503599627370496))/243875 - (6657*119^(1/2)*9755^(1/2)*exp(-7/10)*cos(1951^(1/2)/10 - 4958488623312519/4503599627370496))/243875

Sign in to comment.

Answers (1)

No, those are the solved form of the answers.
You are using solve(). solve() is for obtaining all of the indefinitely precise closed form solutions whenever possible; if not possible then it tries for all of the indefinitely precise semi-open-form solutions (e.g., might include a call to beta() or gamma() or erf()); if not possible then it goes for one software-floating-point solution.
Your equations lend themselves to indefinitely precise closed form solutions, so that is what you get. Those are the exact solutions to your equations in the form given.
Your equations cannot justify using exact solutions. Look at them:
s.v0 = 0.7;
What does that mean in the context of asking for an indefinitely precise solution? According to standard scientific error analysis, you must treat any value given as a decimal fraction as representing some undefined number that rounds to the given one. s.v0 is, for scientific equation purposes, some number in the range [0.65, 0.75) which is a semi-open interval. In order to ask for a proper exact solution, your calculation would have to be able to calculate the result for all numbers in that range, not for only one specific number in that range. You would need to use something like
syms delta_v0 real
assume(-0.05 <= delta_v0 & delta_v0 < 0.05)
s.v0 = 0.7 + delta_v0;
and likewise for the other two constants you give in decimal form. This would lead you to a solution variables in terms of the three unresolved variables delta_v0, delta_vdot0, delta_c, and that would be the result. You could then proceed from there to determine the interval of possible results for the variable, but the "correct" solution is every possible number in that range.
This is what it means to use solve(). Infinitely exact if infinitely exact can be represented.
If you did not want the exact solutions to your equations, you probably should not have used solve(). vpasolve() perhaps.
But the answer you are probably looking for instead of a lecture from me: use double() on your symbolic variables if they do not contain any unresolved variables and you want an IEEE 754 Double Precision approximation of the value of the expression. If they do contain unresolved variables, then use vpa() on the expression to get a software-floating-point approximation of the expression.

Asked:

on 27 Sep 2019

Answered:

on 27 Sep 2019

Community Treasure Hunt

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

Start Hunting!