How can I simplify the division of big numbers?

4 views (last 30 days)
My code is as:
////////////////
clear all
close all
clc
syms T_1 T_2 T_3 T_4 N_1 N_2 N_3 N_4
%%Initioal Conditions
eps=1;L=2.5;l_13=1.5;g=9.8;ra_1=0.5;ra_2=0.8;ra_3=0.6;ra_4=0.7;m_1=10;m_2=20;m_3=15;m_4=17;alpha_12=-pi/3;
alpha_34=-pi/3;Phi=-pi/3;Theta_1=-pi/2;Theta_2=0;Theta_3=0;Theta_4=-pi/2;
%%Equations
Deltaalpha=alpha_34-alpha_12;
alpha_13=-asin(L*sin(Deltaalpha)/(2*l_13));
SigmaF_x =T_1*cos(Theta_1) + T_2*cos(Theta_2) + T_3*cos(Theta_3) + T_4*cos(Theta_4) + N_1*cos(Phi)*sin(Theta_1) + N_2*cos(Phi)*sin(Theta_2) + N_3*cos(Phi)*sin(Theta_3) + N_4*cos(Phi)*sin(Theta_4);
SigmaF_z =N_1*cos(Phi)*cos(Theta_1) - g*m_2 - g*m_3 - g*m_4 - T_1*sin(Theta_1) - T_2*sin(Theta_2) - T_3*sin(Theta_3) - T_4*sin(Theta_4) - g*m_1 + N_2*cos(Phi)*cos(Theta_2) + N_3*cos(Phi)*cos(Theta_3) + N_4*cos(Phi)*cos(Theta_4);
SigmaM_x =N_4*sin(Phi)*(l_13*sin(Phi + alpha_13) + L*sin(alpha_34)) - l_13*(g*m_4 + T_4*sin(Theta_4) - N_4*cos(Phi)*cos(Theta_4)) - l_13*(g*m_3 + T_3*sin(Theta_3) - N_3*cos(Phi)*cos(Theta_3)) + N_3*l_13*sin(Phi + alpha_13)*sin(Phi) + L*N_2*sin(Phi)*sin(alpha_12) + T_1*ra_1*sin(Phi)*sin(Theta_1) + T_2*ra_2*sin(Phi)*sin(Theta_2) + T_3*ra_3*sin(Phi)*sin(Theta_3) + T_4*ra_4*sin(Phi)*sin(Theta_4);
SigmaM_y =(l_13*sin(Phi + alpha_13) + L*sin(alpha_34))*(T_4*cos(Theta_4) + N_4*cos(Phi)*sin(Theta_4)) + L*(g*m_2 + T_2*sin(Theta_2) - N_2*cos(Phi)*cos(Theta_2)) + L*(g*m_4 + T_4*sin(Theta_4) - N_4*cos(Phi)*cos(Theta_4)) + l_13*sin(Phi + alpha_13)*(T_3*cos(Theta_3) + N_3*cos(Phi)*sin(Theta_3)) + L*sin(alpha_12)*(T_2*cos(Theta_2) + N_2*cos(Phi)*sin(Theta_2)) + T_1*ra_1*cos(Phi) + T_2*ra_2*cos(Phi) + T_3*ra_3*cos(Phi) + T_4*ra_4*cos(Phi);
SigmaM_z =T_1*ra_1*cos(Theta_1)*sin(Phi) - l_13*(T_4*cos(Theta_4) + N_4*cos(Phi)*sin(Theta_4)) - L*N_2*sin(Phi) - L*N_4*sin(Phi) - l_13*(T_3*cos(Theta_3) + N_3*cos(Phi)*sin(Theta_3)) + T_2*ra_2*cos(Theta_2)*sin(Phi) + T_3*ra_3*cos(Theta_3)*sin(Phi) + T_4*ra_4*cos(Theta_4)*sin(Phi);
sixthEq =N_2*T_1 - N_1*T_2;
seventhEq =N_3*T_2 - N_2*T_3;
%%Solve
SOL=solve([SigmaF_x,SigmaF_z,SigmaM_x,SigmaM_y,SigmaM_z,sixthEq,seventhEq],[T_1,T_2,T_3,T_4,N_1,N_2,N_3]);
Result=vpa(SOL.T_1,3)
////////////////
Why the Result has a lot of big numbers; however, it easily can be seen that if Matlab divide these big numbers, the answers are not too big?!. For instance, the answer has numbers as big as 1e1493 divided by 1490?! but MatLab is unable to divide these numbers.
Regards

Answers (1)

Walter Roberson
Walter Roberson on 16 May 2016
vpa(simplify(Result),3)
  3 Comments
Meysam E
Meysam E on 16 May 2016
If Matlab simplify those divisions such as 1e2014/1e2010 the problem is solved!
Walter Roberson
Walter Roberson on 16 May 2016
No, I ran the calculation to 50000 digits of precision and it was still getting the wrong answer, with the order of magnitude changing significantly (sometimes worse) as the number of digits of precision increased. The equation is very bad numerically and any answer you are getting is almost certainly wrong.

Sign in to comment.

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!