| Michael Day on Thu, 19 Nov 2026 21:41:15 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Qn about execution of Multinomial expressions |
In an expression like1/4*b^2*x^4 + (b^2*i - 1/2*b^2)*x^3 + (b^2*i^2 - b^2*i + (1/4*b^2 + p*b))*x^2 + (2*p*b*i - p*b)*x + p^2 does the interpreter recalculate repeated terms such as b^2 at each appearance or
does it save their values for reuse? (This is only a fairly simple example.) Hitherto, I've been precalculating such values in a my() statement, eg my(b2=b^2, x2=x^2, x3=x*x2,x4=x3+x, ....) ; \\ followed by1/4*b2*x4 + (b2*i - 1/2*b2)*x3 + (b2*i2 - b2*i + (1/4*b2 + p*b))*x2 + (2*p*b*i - p*b)*x + p2
but do I need to do so to improve calculation speed?It's easy to make mistakes hand-coding the necessary (?) alterations in much longer
such expressions. Thanks, Mike NB - I know that the above expression is a square of a simpler one. I just wanted to give a better idea of the complexity. -- This email has been checked for viruses by Avast antivirus software. www.avast.com