Simplify expression after collect function

5 views (last 30 days)
Hello I have written a code that performs newton interpolation. After I determined the coefficients I want to display the simplified expression like this: p(x) = p14*x^14 + p13*x^13 + ... + p0
But when I use the collect function it displays the result as follows:
((1613572414787747*13^(1/2)*17^(1/2))/1667355148462087077893881565539536391777188164935759167488 + (1613572414787747*22^(1/2))/2157753721539171512568552614227635330535184684034511863808 + 3914999446024239438846407105870793530675/11373727500204176163375146989836406690440670303259304015465585573888)*X^14 + ...
I would like to display 3.4421e-28*X^14 + ...
How do I do that?
This is the code I used to create formula out of th calculated cofficients:
%display the formula (collect or factor function)
syms X;
p_x = collect( a(1)...
+ a(2)*(X-x(1))...
+ a(3)*(X-x(1))*(X-x(2))...
+ a(4)*(X-x(1))*(X-x(2))*(X-x(3))...
+ a(5)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))...
+ a(6)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))...
+ a(7)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))*(X-x(6))...
+ a(8)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))*(X-x(6))*(X-x(7))...
+ a(9)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))*(X-x(6))*(X-x(7))*(X-x(8))...
+ a(10)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))*(X-x(6))*(X-x(7))*(X-x(8))*(X-x(9))...
+ a(11)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))*(X-x(6))*(X-x(7))*(X-x(8))*(X-x(9))*(X-x(10))...
+ a(12)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))*(X-x(6))*(X-x(7))*(X-x(8))*(X-x(9))*(X-x(10))*(X-x(11))...
+ a(13)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))*(X-x(6))*(X-x(7))*(X-x(8))*(X-x(9))*(X-x(10))*(X-x(11))*(X-x(12))...
+ a(14)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))*(X-x(6))*(X-x(7))*(X-x(8))*(X-x(9))*(X-x(10))*(X-x(11))*(X-x(12))*(X-x(13))...
+ a(15)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))*(X-x(6))*(X-x(7))*(X-x(8))*(X-x(9))*(X-x(10))*(X-x(11))*(X-x(12))*(X-x(13))*(X-x(14))...
+ a(16)*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))*(X-x(6))*(X-x(7))*(X-x(8))*(X-x(9))*(X-x(10))*(X-x(11))*(X-x(12))*(X-x(13))*(X-x(14))*(X-x(15))...
, X )
Thanks in advance!

Accepted Answer

Walter Roberson
Walter Roberson on 12 Feb 2016
call vpa() on the expression.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox 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!