Simplifying output in Matlab
Show older comments
If you get an expression like this as output
syms x
fx = -(1.0*(1.82e+39*x^2 + 1.81e+32*x - 3.04e+39))/(6.35e+41*x + 4.27e+37)
How do you simplify the output and use smaller numbers, for example
fx = -(1.0*(1.82e+7*x^2 + 1.81*x - 3.04e+7))/(6.35e+9*x + 4.27e+5)
6 Comments
Likely the best to be hoped for is —
syms x
fx = -(1.0*(1.82e+39*x^2 + 1.81e+32*x - 3.04e+39))/(6.35e+41*x + 4.27e+37)
fx = vpa(fx, 3)
fx = vpa(simplifyFraction(fx), 3)
.
Aleem Andrew
on 7 Nov 2021
Walter Roberson
on 7 Nov 2021
Is the rule that you want the numerator coefficient of x^1 to be in the range [1, 10) ?
Aleem Andrew
on 7 Nov 2021
Star Strider
on 7 Nov 2021
The integration proceeded very quickly, running it in Input argument for ode45 function type error (running R2021b), however the coefficient magnitudes are large, although not so different between them that this could be regarded as a ‘stiff’ system. It could be worth experimenting with ode15s or other stiff solvers to see if the speed increases significantly.
Jan
on 7 Nov 2021
The computation of smaller numbers is easier for human, but does not change the speed when performing the calculations on a computer.
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differential Equations 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!
