Symbolic Output Display Problem
3 views (last 30 days)
Show older comments
Christopher Kube
on 10 Jun 2014
Answered: Christopher Creutzig
on 1 Sep 2014
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 Comments
Accepted Answer
Star Strider
on 10 Jun 2014
3 Comments
Star Strider
on 10 Jun 2014
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.
More Answers (1)
Christopher Creutzig
on 1 Sep 2014
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 Comments
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!