Plus42 Equations, Preview Release
|
03-30-2022, 07:06 PM
(This post was last modified: 03-30-2022 07:47 PM by Albert Chan.)
Post: #477
|
|||
|
|||
RE: Plus42 Equations, Preview Release
I think complex powers with integer exponents should be done via squaring.
This is true even if result is not exact. Y^X = |Y|^X * cis(arg(Y)*X) Unlike pow() for real, we don't have excess precision to correct close to actual result. Essentially, we are getting this, from Free42/Plus42: Y^X ≈ round(round(|Y|)^X) * cis(round(round(arg(Y))*X)) Worst, argument inside cis() would required reduction, to within ±pi. Python already does integer powers by squaring. Complex pow (last column) not as good. Python 3.9.5 (default, May 27 2021, 19:45:35) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> z = 3+4j >>> q = 2+1j # sqrt(z) >>> for i in range(10): print(i, q*z**i, z**(i+0.5)) ... 0 (2+1j) (2+1j) 1 (2+11j) (2.0000000000000013+11j) 2 (-38+41j) (-37.999999999999986+41.00000000000001j) 3 (-278-29j) (-278-28.99999999999994j) 4 (-718-1199j) (-718.0000000000008-1198.9999999999995j) 5 (2642-6469j) (2641.9999999999964-6469.000000000001j) 6 (33802-8839j) (33801.99999999999-8839.000000000015j) 7 (136762+108691j) (136762.00000000006+108690.99999999996j) 8 (-24478+873121j) (-24477.99999999971+873121j) 9 (-3565918+2521451j) (-3565917.9999999995+2521451.000000001j) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)