$y = x (a - x) (x - 1)$ how to efficiently compute $y$ and $x^3$ efficiently?

41 Views Asked by At

specifically i'm giving this operation $x(a - x) (x - 1)$ a bunch of times the GPU to compute as part of a bigger project. considering a low precision 16 bit maybe 32 bit ($n \log(n)$ does not take advantage not sure though) like i know there is a way of computing $x^2$ faster than $xy$ by reusing the bits when computing it using it's symmetries. i cannot find a way to do $a^3$ faster though as i don't know how to phrase the question without getting random side-quests results.

so my idea is to compute $x^2$ and $x^3$ (assuming it's faster then $x^2$ times $x$) beforehand and then do: $a(x^2 - x) - x^3 + x^2$, so I can reuse $x^2$ and get only something to multiply by $a$...

Is my approach fine? or is there a way of rephrasing the question? or just give $x(a - x)(x - 1)$ to the GPU as is? P.S. also i don't care too much about the precision of the calculation so maybe that helps in some ways but not sure how to approach the problem.