by moonchild · 2y ago · 0 comments
i think aa is linear in the number of terms, and reduced aa is linear in the number of independent variables, but possibly i don't understand your meaning
if you have an expression with n terms, then you will end up with O(n) terms each taking up O(n) space, so the overall space usage is quadratic. (that's the fair way to compare to polyhedra since they're always global)
on the other hand, if i am merely evaluating a polynomial with n terms, such as 3x⁴ - 2x³ + 17x² + x - 4 for n = 5, i only have three aa objects at any one time during evaluation of the expression, regardless of n. in this case the program might look like this
a ← x; a ← a⁴; b ← 3; a ← a · b
b ← x; b ← b³; c ← -2; b ← b · c; a ← a + b
b ← x; b ← b²; c ← 17; b ← b · c; a ← a + b
b ← x; a ← a + b
b ← -4; a ← a + b
this assumes we have three registers for aa objects, creatively called a, b, and c; that we can only do arithmetic on these registers; and that the power operations are unary (otherwise they require an additional register)this is true of any polynomial
with horner's-rule evaluation we can cut this down to two registers
a ← 3
b ← x; a ← a · b; b ← -2; a ← a + b
b ← x; a ← a · b; b ← 17; a ← a + b
b ← x; a ← a · b; b ← 1; a ← a + b
b ← x; a ← a · b; b ← -4; a ← a + b
obviously there do exist expressions with deeper minimum evaluation stacks, but i think they're only worst-case logarithmic in expression size, aren't they?