joshuabowers / graphca

A graphing calculator and analytic calculus engine
MIT License
0 stars 0 forks source link

Pre-calculate the modulus and argument of Complexes #3

Closed joshuabowers closed 2 years ago

joshuabowers commented 3 years ago

At the cost of extra storage (of two real-valued numbers) per Complex, the modulus and the argument of the complex could be calculated at instantiation, so long as the Complex remain immutable. This would benefit functions which require the Complex to be represented in polar form, as these values would not need to be recalculated per call.

Memory vs algorithmic efficiency. The eternal struggle.

(The Complex could be stored internally in polar form, but doing so would require many of the other operations to be either rewritten in terms of polar arithmetic, or would require Cartesian equivalents to be calculated on demand. Hence, potentially storing both tuples.)

joshuabowers commented 2 years ago

As part of the functional rewrite, complex numbers were slightly redesigned to be integrated into the functional representations of various operations. As such, there is little merit in pursuing this.