MATLAB Answers

obtaining large numbers while using syms

조회 수: 16(최근 30일)
mojtaba najafi
mojtaba najafi 2020년 12월 31일
답변: Walter Roberson 2020년 12월 31일
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
Walter Roberson
Walter Roberson 2020년 12월 31일
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)];

댓글을 달려면 로그인하십시오.

답변(2개)

Ameer Hamza
Ameer Hamza 2020년 12월 31일
Specify the number of digits in vpa() to
vpa(x, 4)
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2020년 12월 31일
What type of simplification do you want? The polynomials in numerators or denominators cannot be further simplified.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2020년 12월 31일
%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 = 

Community Treasure Hunt

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

Start Hunting!

Translated by