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!