[math-fun] terse transcendence
with just double, triple, and small angle formulas: In[631]:= sin[x_] := x /; Abs[x - x^2] == Abs@x; sin[x_] := #*(3 - 4*#^2) &@sin[x/3] In[634]:= sin[Pi/3`33]^2 Out[634]= 0.75000000000000000000000000000000 In[633]:= sin[Pi/2`33 - I] - sin[I*1`33] I // tim During evaluation of In[633]:= 0.003148,0 Out[633]= 2.71828182845904523536028747135265 + 0.*10^-33 I In[682]:= Log@%633 Out[682]= 0.999999999999999999999999999999997 + 0.*10^-33 I In[673]:= asin[x_] := 2 asin[x/(Sqrt[1 - x] + Sqrt[1 + x])]; asin[x_] := x /; Abs[x + x^2] == Abs[x] In[674]:= 2 asin@1`33 Out[674]= 3.141592653589793 (We lose half our digits near turning points.) In[683]:= 6 asin[.5`33] // tim During evaluation of In[683]:= 0.002256,0 Out[683]= 3.14159265358979323846264338327950 versin[x_] := x^2/2 /; Abs[x] == Abs[x + x^2]; versin[x_] := 2 (2 - #) # &@versin[x/2] versin[Pi/5`33] 0.190983005625052575897706582817181 (3 - 4 %)^2 5.00000000000000000000000000000000 In[663]:= tan[x_] := x /; Abs[x + x^2] == Abs@x; tan[x_] := 2 #/(1 - #^2) &@tan[x/2] In[665]:= tan[Pi/4`33] Out[665]= 1.00000000000000000000000000000000 In[668]:= (# + I)/(I - #) &@tan[I/2`33] Out[668]= 2.71828182845904523536028747135284 In[669]:= Log@% Out[669]= 1.00000000000000000000000000000007 Unfortunately, due to excessive significance pessimism, this terse weierstrass p only works on machine floats: In[326]:=weierp[z_, g2_, g3_] := z^-2 /; Abs[z] == Abs[z + z^2] In[327]:= weierp[z_, g2_, g3_] := (g2/4 - 3 #^2)^2/((4 #^2 - g2) # - g3) - 2 # &@ weierp[z/2, g2, g3] In[328]:= weierp[#, 2, 0] & /@ WeierstrassHalfPeriods[{2., 0}] Out[328]= {0.707106781186547 + 0.*I, -0.707106781186547 + 0.*I} Overriding the pessimism defeats the terseness: weierp[z_, g2_, g3_] := (g2^2 + 32 g3 #1 + 8 g2 #1^2 + 16 #1^4)/( 16 (-g3 - g2 #1 + 4 #1^3)) &@SetPrecision[weierp[z/2, g2, g3], 44] In[357]:= SetPrecision[ weierp[#, 0, 3] & /@ WeierstrassHalfPeriods[{0, 3.}], 22] Out[357]= {0.9085602964160698294456, -0.4542801482080349147228 + 0.7868362975662361391456 I} In[358]:= %^3 Out[358]= {0.750000000000000000000, 0.750000000000000000000 + 0.*10^-22 I} Unlike with arcsin, I have yet to figure out how to extend this technique to InverseWeierstrassP (which we need for NeilB's rational squares in arithmetic progression formula). --rwg
participants (1)
-
Bill Gosper