Simplify expression after collect function

1 回表示 (過去 30 日間)
Tom Klijn
Tom Klijn 2016 年 2 月 12 日
回答済み: Walter Roberson 2016 年 2 月 12 日
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!

採用された回答

Walter Roberson
Walter Roberson 2016 年 2 月 12 日
call vpa() on the expression.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by