Quick question, Horners schema of polynoms is not recommended in Stan, example:
4 + x*(3 + x*(6 + x*(10 + x*(1 + x))))
as its expansion in autodiff is less efficient?
True or Not?
Quick question, Horners schema of polynoms is not recommended in Stan, example:
4 + x*(3 + x*(6 + x*(10 + x*(1 + x))))
as its expansion in autodiff is less efficient?
True or Not?
You mean compared to
4 + 3 * x + 6 * x^2 + ...
?
You need to figure out what the expression graphs look like in both cases.
Horner’s: multiply-add for each order above zero
Canonical: multiply-add and power for each order above zero
But what we really need to know is where is the autodiff:
Horner’s: double + var
and var * var
for each order
Canonical: var + var
, double * var
, and pow(var, double)
for each order
My guess would be that Horner’s form will be more efficient. I have no idea which is more numerically stable.