obtaining large numbers while using syms

44 views (last 30 days)
mojtaba najafi
mojtaba najafi on 31 Dec 2020
Answered: Walter Roberson on 31 Dec 2020
Hello, I have a matrix which vontains symbols:
kesi_eta=[1/sqrt(3) 1/sqrt(3)
-1/sqrt(3) 1/sqrt(3)
-1/sqrt(3) -1/sqrt(3)
1/sqrt(3) -1/sqrt(3)];
Kij_new=0;
for i=1:4
kesi=kesi_eta(i,1);
eta=kesi_eta(i,2);
B=(1/4).*[1+eta 0 -1-eta 0 -1+eta 0 1-eta 0
0 1+kesi 0 1-kesi 0 -1+kesi 0 -1-kesi
1+kesi 1+eta 1-kesi -1-eta -1+kesi -1+eta -1-kesi 1-eta];
J=[Lx/2 0
0 Ly/2];
Bhat=(1/(2*Lx*Ly)).*[Ly*(1+eta) 0 -Ly*(1+eta) 0 -Ly*(1-eta) 0 Ly*(1-eta) 0
0 Lx*(1+kesi) 0 Lx*(1-kesi) 0 -Lx*(1-kesi) 0 -Lx*(1+kesi)
Lx*(1+kesi) Ly*(1+eta) Lx*(1-kesi) -Ly*(1+eta) -Lx*(1-kesi) -Ly*(1-eta) -Lx*(1+kesi) Ly*(1-eta)];
D_red=[1/E -v/E 0;
-v/E 1/E 0;
0 0 1/G];
C=D_red^-1;
Kij=Bhat.'*C*Bhat*h*det(J);
Kij1=Kij;
Kij_old=Kij_new+Kij1;
Kij_new=Kij_old;
end
and the out put gives me very large numbers without simplification.even when I use function simplify(), I face these numbers:
[ (72115234146317045769238718114163*E*h*(9*v - 17))/(2596148429267413814265248164610048*(v^2 - 1)), -(324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), (3*E*h*(13521606402434444180830355908725*v + 10516804979671237742249216795996))/(324518553658426726783156020576256*(v^2 - 1)), -(324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), -(4507202134144814726943451969575*E*h*(9*v - 17))/(324518553658426726783156020576256*(v^2 - 1)), (324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), -(3*E*h*(216345702438951137307716154342489*v - 120192056910528423132922512324889))/(2596148429267413814265248164610048*(v^2 - 1)), (324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1))]
[ -(324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), (72115234146317045769238718114163*E*h*(2*v - 11))/(1298074214633706907132624082305024*(v^2 - 1)), (324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), -(3*E*h*(24038411382105681923079572704721*v + 30048014227632094800241850930179))/(649037107316853453566312041152512*(v^2 - 1)), (324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), -(4507202134144814726943451969575*E*h*(2*v - 11))/(162259276829213363391578010288128*(v^2 - 1)), -(324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), (3*E*h*(24038411382105678543698410504400*v + 192307291056845458764017743838089))/(1298074214633706907132624082305024*(v^2 - 1))]
[ (3*E*h*(13521606402434444180830355908725*v + 10516804979671237742249216795996))/(324518553658426726783156020576256*(v^2 - 1)), (324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), (72115234146317045769238718114163*E*h*(9*v - 17))/(2596148429267413814265248164610048*(v^2 - 1)), (324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), -(3*E*h*(216345702438951137307716154342489*v - 120192056910528423132922512324889))/(2596148429267413814265248164610048*(v^2 - 1)), -(324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), -(4507202134144814726943451969575*E*h*(9*v - 17))/(324518553658426726783156020576256*(v^2 - 1)), -(324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1))]
[ -(324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), -(3*E*h*(24038411382105681923079572704721*v + 30048014227632094800241850930179))/(649037107316853453566312041152512*(v^2 - 1)), (324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), (72115234146317045769238718114163*E*h*(2*v - 11))/(1298074214633706907132624082305024*(v^2 - 1)), (324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), (3*E*h*(24038411382105678543698410504400*v + 192307291056845458764017743838089))/(1298074214633706907132624082305024*(v^2 - 1)), -(324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), -(4507202134144814726943451969575*E*h*(2*v - 11))/(162259276829213363391578010288128*(v^2 - 1))]
[ -(4507202134144814726943451969575*E*h*(9*v - 17))/(324518553658426726783156020576256*(v^2 - 1)), (324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), -(3*E*h*(216345702438951137307716154342489*v - 120192056910528423132922512324889))/(2596148429267413814265248164610048*(v^2 - 1)), (324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), (72115234146317045769238718114163*E*h*(9*v - 17))/(2596148429267413814265248164610048*(v^2 - 1)), -(324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), (3*E*h*(13521606402434444180830355908725*v + 10516804979671237742249216795996))/(324518553658426726783156020576256*(v^2 - 1)), -(324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1))]
[ (324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), -(4507202134144814726943451969575*E*h*(2*v - 11))/(162259276829213363391578010288128*(v^2 - 1)), -(324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), (3*E*h*(24038411382105678543698410504400*v + 192307291056845458764017743838089))/(1298074214633706907132624082305024*(v^2 - 1)), -(324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), (72115234146317045769238718114163*E*h*(2*v - 11))/(1298074214633706907132624082305024*(v^2 - 1)), (324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), -(3*E*h*(24038411382105681923079572704721*v + 30048014227632094800241850930179))/(649037107316853453566312041152512*(v^2 - 1))]
[ -(3*E*h*(216345702438951137307716154342489*v - 120192056910528423132922512324889))/(2596148429267413814265248164610048*(v^2 - 1)), -(324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), -(4507202134144814726943451969575*E*h*(9*v - 17))/(324518553658426726783156020576256*(v^2 - 1)), -(324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), (3*E*h*(13521606402434444180830355908725*v + 10516804979671237742249216795996))/(324518553658426726783156020576256*(v^2 - 1)), (324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), (72115234146317045769238718114163*E*h*(9*v - 17))/(2596148429267413814265248164610048*(v^2 - 1)), (324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1))]
[ (324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), (3*E*h*(24038411382105678543698410504400*v + 192307291056845458764017743838089))/(1298074214633706907132624082305024*(v^2 - 1)), -(324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), -(4507202134144814726943451969575*E*h*(2*v - 11))/(162259276829213363391578010288128*(v^2 - 1)), -(324518553658426690754359001612289*E*h*(3*v - 1))/(2596148429267413814265248164610048*(v^2 - 1)), -(3*E*h*(24038411382105681923079572704721*v + 30048014227632094800241850930179))/(649037107316853453566312041152512*(v^2 - 1)), (324518553658426690754359001612289*E*h)/(2596148429267413814265248164610048*(v - 1)), (72115234146317045769238718114163*E*h*(2*v - 11))/(1298074214633706907132624082305024*(v^2 - 1))]
Can someone pleaaase help me? I have even used vpa() and still the problem has not been fixed
thank you
  1 Comment
Walter Roberson
Walter Roberson on 31 Dec 2020
Sqrt = @(x) sqrt(sym(x)) ;
kesi_eta=[1/Sqrt(3) 1/Sqrt(3)
-1/Sqrt(3) 1/Sqrt(3)
-1/Sqrt(3) -1/Sqrt(3)
1/Sqrt(3) -1/Sqrt(3)];

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 31 Dec 2020
%variables user did not define. Give them a definite value.
h = sym(5/3); E = sym(10000); v = sym(123); Lx = sym(28); Ly = sym(18); G = sym(42);
%proceed
Sqrt = @(x) sqrt(sym(x)) ;
kesi_eta=[1/Sqrt(3) 1/Sqrt(3)
-1/Sqrt(3) 1/Sqrt(3)
-1/Sqrt(3) -1/Sqrt(3)
1/Sqrt(3) -1/Sqrt(3)];
Kij_new=0;
for i=1:4
kesi=kesi_eta(i,1);
eta=kesi_eta(i,2);
B=(1/4).*[1+eta 0 -1-eta 0 -1+eta 0 1-eta 0
0 1+kesi 0 1-kesi 0 -1+kesi 0 -1-kesi
1+kesi 1+eta 1-kesi -1-eta -1+kesi -1+eta -1-kesi 1-eta];
J=[Lx/2 0
0 Ly/2];
Bhat=(1/(2*Lx*Ly)).*[Ly*(1+eta) 0 -Ly*(1+eta) 0 -Ly*(1-eta) 0 Ly*(1-eta) 0
0 Lx*(1+kesi) 0 Lx*(1-kesi) 0 -Lx*(1-kesi) 0 -Lx*(1+kesi)
Lx*(1+kesi) Ly*(1+eta) Lx*(1-kesi) -Ly*(1+eta) -Lx*(1-kesi) -Ly*(1-eta) -Lx*(1+kesi) Ly*(1-eta)];
D_red=[1/E -v/E 0;
-v/E 1/E 0;
0 0 1/G];
C=D_red^-1;
Kij=Bhat.'*C*Bhat*h*det(J);
Kij1=Kij;
Kij_old=Kij_new+Kij1;
Kij_new=Kij_old;
end
simplify(Kij_new)
ans = 

Ameer Hamza
Ameer Hamza on 31 Dec 2020
Specify the number of digits in vpa() to
vpa(x, 4)
  2 Comments
mojtaba najafi
mojtaba najafi on 31 Dec 2020
thank you for your answer.but now I reach something like this:
vpa(ans,4)
ans =
[ (1.541e-33*(7.569e+31*v - 8.053e+31))/(v^2 - 1.0), -0.02083/(v - 1.0), (7.704e-34*(4.056e+31*v - 3.09e+31))/(v^2 - 1.0), -(7.704e-34*(4.154e+31*v - 2.704e+31))/(v^2 - 1.0), -(7.704e-34*(4.056e+31*v - 7.662e+31))/(v^2 - 1.0), -(7.704e-34*(8.643e+31*v - 1.009e+32))/(v^2 - 1.0), -(3.081e-33*(3.785e+31*v - 2.883e+31))/(v^2 - 1.0), (3.081e-33*(3.875e+31*v - 2.523e+31))/(v^2 - 1.0)]
[ -0.02083/(v - 1.0), (7.704e-34*(4.831e+30*v - 3.076e+32))/(v^2 - 1.0), (3.852e-34*(1.227e+32*v - 1.449e+31))/(v^2 - 1.0), -(7.704e-34*(4.831e+30*v + 7.63e+31))/(v^2 - 1.0), (3.852e-34*(3.892e+32*v + 1.449e+31))/(v^2 - 1.0), -(1.541e-33*(9.014e+30*v - 4.958e+31))/(v^2 - 1.0), -(1.541e-33*(1.144e+32*v - 1.352e+31))/(v^2 - 1.0), (3.081e-33*(4.507e+30*v + 7.119e+31))/(v^2 - 1.0)]
[ (7.704e-34*(4.056e+31*v - 3.09e+31))/(v^2 - 1.0), (3.852e-34*(1.227e+32*v - 1.449e+31))/(v^2 - 1.0), (1.926e-34*(4.348e+31*v - 8.212e+31))/(v^2 - 1.0), 0.005582/(v - 1.0), -(1.926e-34*(4.348e+31*v + 1.008e+32))/(v^2 - 1.0), -(7.704e-34*(4.154e+31*v - 2.704e+31))/(v^2 - 1.0), -(7.704e-34*(4.056e+31*v - 7.662e+31))/(v^2 - 1.0), -0.02083/(v - 1.0)]
[ -(7.704e-34*(4.154e+31*v - 2.704e+31))/(v^2 - 1.0), -(7.704e-34*(4.831e+30*v + 7.63e+31))/(v^2 - 1.0), 0.005582/(v - 1.0), (3.852e-34*(9.662e+30*v - 5.314e+31))/(v^2 - 1.0), (3.852e-34*(1.227e+32*v - 1.449e+31))/(v^2 - 1.0), (3.852e-34*(3.606e+31*v + 7.42e+30))/(v^2 - 1.0), -0.02083/(v - 1.0), -(1.541e-33*(9.014e+30*v - 4.958e+31))/(v^2 - 1.0)]
[ -(7.704e-34*(4.056e+31*v - 7.662e+31))/(v^2 - 1.0), (3.852e-34*(3.892e+32*v + 1.449e+31))/(v^2 - 1.0), -(1.926e-34*(4.348e+31*v + 1.008e+32))/(v^2 - 1.0), (3.852e-34*(1.227e+32*v - 1.449e+31))/(v^2 - 1.0), (1.926e-34*(4.348e+31*v - 5.818e+32))/(v^2 - 1.0), -0.02083/(v - 1.0), (7.704e-34*(4.056e+31*v + 9.4e+31))/(v^2 - 1.0), -(1.541e-33*(1.144e+32*v - 1.352e+31))/(v^2 - 1.0)]
[ -(7.704e-34*(8.643e+31*v - 1.009e+32))/(v^2 - 1.0), -(1.541e-33*(9.014e+30*v - 4.958e+31))/(v^2 - 1.0), -(7.704e-34*(4.154e+31*v - 2.704e+31))/(v^2 - 1.0), (3.852e-34*(3.606e+31*v + 7.42e+30))/(v^2 - 1.0), -0.02083/(v - 1.0), (3.852e-34*(1.346e+32*v - 1.78e+32))/(v^2 - 1.0), (3.081e-33*(3.875e+31*v - 2.523e+31))/(v^2 - 1.0), -(1.541e-33*(3.364e+31*v + 6.923e+30))/(v^2 - 1.0)]
[ -(3.081e-33*(3.785e+31*v - 2.883e+31))/(v^2 - 1.0), -(1.541e-33*(1.144e+32*v - 1.352e+31))/(v^2 - 1.0), -(7.704e-34*(4.056e+31*v - 7.662e+31))/(v^2 - 1.0), -0.02083/(v - 1.0), (7.704e-34*(4.056e+31*v + 9.4e+31))/(v^2 - 1.0), (3.081e-33*(3.875e+31*v - 2.523e+31))/(v^2 - 1.0), (3.081e-33*(3.785e+31*v - 7.149e+31))/(v^2 - 1.0), 0.07775/(v - 1.0)]
[ (3.081e-33*(3.875e+31*v - 2.523e+31))/(v^2 - 1.0), (3.081e-33*(4.507e+30*v + 7.119e+31))/(v^2 - 1.0), -0.02083/(v - 1.0), -(1.541e-33*(9.014e+30*v - 4.958e+31))/(v^2 - 1.0), -(1.541e-33*(1.144e+32*v - 1.352e+31))/(v^2 - 1.0), -(1.541e-33*(3.364e+31*v + 6.923e+30))/(v^2 - 1.0), 0.07775/(v - 1.0), (6.163e-33*(8.411e+30*v - 4.626e+31))/(v^2 - 1.0)]
As you can see it is not a reaconable answer.
Ameer Hamza
Ameer Hamza on 31 Dec 2020
What type of simplification do you want? The polynomials in numerators or denominators cannot be further simplified.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!