Symbolic Output Display Problem
조회 수: 9 (최근 30일)
이전 댓글 표시
I have a long symbolic expression where the output display gives unwanted fraction representations. An example of the output is given below. The unwanted fraction is given in bold. I've attached the m.file used to generate the output. You can see that this fraction is not contained in the input definition of c111r. I have tried various commands such as "sym(5^(1/2))" to prevent this from happening without success. Any help would be greatly appreciated. I am using MatlabR2013b.
c111r =
(((((c11 + c12)/((c11 - c12)*(c11 + 2*c12)) - 1/(2*c44) + c12/((c11 - c12)*(c11 + 2*c12)))*((16*2^(1/2)*pi^2*W400)/35 + (16*5^(1/2)*pi^2*W420)/35 - 1/5) + c12/((c11 - c12)*(c11 + 2*c12)))*(((c11 + c12)/((c11 - c12)*(c11 + 2*c12)) - 1/(2*c44) + c12/((c11 - c12)*(c11 + 2*c12)))*((16*5^(1/2)*pi^2*W420)/35 - (16*2^(1/2)*pi^2*W400)/35 + 1/5) - c12/((c11 - c12)*(c11 + 2*c12))) + (((c11 + c12)/((c11 - c12)*(c11 + 2*c12)) - 1/(2*c44) + c12/((c11 - c12)*(c11 + 2*c12)))*((4*2^(1/2)*pi^2*W400)/35 - (8*35^(1/2)*pi^2*W440)/35 + 1/5) - c12/((c11 - c12)*(c11 + 2*c12)))*(1/(2*c44) + ((32*2^(1/2)*pi^2*W400)/35 + 3/5)*((c11 + c12)/((c11 - c12)*(c11 + 2*c12)) - 1/(2*c44) + c12/((c11 - c12)*(c11 + 2*c12))) - c12/((c11 - c12)*(c11 + 2*c12))))^3*(((3*c144*(c11 + c12))/((c11 - c12)*(c11 + 2*c12)) - (6*c12*c155)/((c11 - c12)*(c11 + 2*c12)))/(2*c44^2) - c112*((6*c12^3)/((c11 - c12)^3*(c11 + 2*c12)^3) + (6*c12*(c11 + c12)^2)/((c11 - c12)^3*(c11 + 2*c12)^3) - (6*c12^2*(c11 + c12))/((c11 - c12)^3*(c11 + 2*c12)^3)) - (((c144*(c11 + c12))/((c11 - c12)*(c11 + 2*c12)) - (2*c12*c155)/((c11 - c12)*(c11 + 2*c12)))/(4*c44^2) - (c155*((c11 + c12)/((c11 - c12)*(c11 + 2*c12)) - c12/((c11 - c12)*(c11 + 2*c12))) - (c12*c144)/((c11 - c12)*(c11 + 2*c12)))/(4*c44^2) + c456/(4*c44^3))* *((269741649381513*pi^2*W420)/21990232555520 + (2497842628749521*pi^2*W440)/153931627888640* +...
댓글 수: 0
채택된 답변
Star Strider
2014년 6월 10일
댓글 수: 3
Star Strider
2014년 6월 10일
Sorry vpa, digits or double didn’t work. I too wish the Symbolic engine resisted the temptation to produce rational fractions by default instead of keeping everything as the integers or fixed-precision floats it started with, unless requested to evaluate them.
My only other suggestion is to experiment with assume. Sometimes that keeps things symbolic when they might otherwise be evaluated.
추가 답변 (1개)
Christopher Creutzig
2014년 9월 1일
If I understand your problem correctly, you don't want approximations as given by vpa. In that case, here's the best advice I can give without seeing your inputs:
Don't use calls like sym(5^(1/2)) (although that particular one works just fine), use sym(5)^(1/2) instead.
If you say, e.g., sym(5^(1/3)), that will be the same as saying sym(1.709975946676697) and will not magically detect that you meant 5^(1/3), not 1925261759066421/1125899906842624. I.e., if your input contains sym(5^(1/3)), it contains a rational number with large numerator and denominator, which will show up in the output.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!