A =
Convert a decimal approximation to exact value symbolically
Show older comments
Hi, I'm working with a definite integral and get a decimal approximation as my answer. I'd like to also get the exact solution:
syms x y
y1=sin(pi*x/2); y2=x; x1=-1; x2=1;
A=int((abs(y2-y1)),x1,x2);
Gives the answer as 0.2732 which is a correct decimal approximation. The exact solution is:
(4-pi)/pi
How do I get that?
Accepted Answer
More Answers (1)
Walter Roberson
on 8 Jul 2025
sympref('FloatingPointOutput',false);
Will display an unevaluated int() form for your original problem, and will display 4/pi - 1 for the version suggested by @Torsten
It seems that you have FloatPointOutput true in effect.
Categories
Find more on Numeric Solvers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!