Multivariate Horner scheme implementation in MATLAB
3 ビュー (過去 30 日間)
I have very long symbolic expressions (mainly polynomials or rational types) and I need to evaluate them many many times. Therefore,
in order to reduce the computational time I would like to re-write my expressions by their equivalent horner form. For instance, the expression
needs f=2*x^3-3*x^2+6*x-5 requires 8 multiplications and 3 additions while its following horner equivalent requires only 3 multiplications and 3 additions:
x*(x*(2*x - 3) + 6) - 5
Unfortunately, matlab only supports a univariate horner scheme. But, my expressions are multivariate and I need a multivariate Horner scheme
to simplify my long multivariate expressions. For instance, consider the following bi-variate expression:
syms x y
f = x^2+2*x*y+y^2;
If I go for a uni-variate Horner scheme then I get
x*(x + 2*y) + y^2
which requires less multiplications. This is, of course, an improvement. But, this is not the best improvement. A bi-variate Horner scheme
should give us (x+y)^2 as the best representation which needs only 2 arithmatics!
So, in sum, I need a matlab code which can implement a multivariate Horner scheme. I could find a python code but nothing in matlab. Unfortunately, I do not know python very well and really need a matlab code.
Any help is GREATLY appreciated!
Thanks in advance,