[math-fun] Mathematica
A youngster wanted an example of a *really* (but not artificially) long computation, so i let this run (and run): In[166]:= Simplify[ComplexExpand[ mobc[Circle[{x, y}, r], 1, u, u, 1]], -1 < u < 1 && {x, y} \[Element] Reals && r > 0] // tim (*This homographically transforms the general Circle[{x, y}, r] by (z+u)/(u z +1), which preserves the unit circle.*) During evaluation of In[166]:= 3.387416,2 (*This printout was from my timing function tim, meaning 3.4 secs, length 2.*) Out[166]= 2 Circle[{-2 Im[(r (-1 + u ) ( 2/3 2/3 r + (-1) (u + x + I y) 2 (-1 + (-1) ) Abs[-------------------------------] 2/3 r u + (-1) (1 + u (x + I y)) ------------------------------------------------------- + 2/3 (1 + r u + u (x + I y)) (1 + (-1) r u + u (x + I y)) r + u + x + I y 2 I Sqrt[3] Abs[---------------------] 1 + r u + u x + I u y (------------------------------------- - 2/3 1 + (-1) r u + u x + I u y 2/3 1/3 (-1) r + u + x + I y 2 (1 + (-1) ) Abs[-----------------------------] 2/3 1 + (-1) r u + u x + I u y -------------------------------------------------) / 1 + r u + u x + I u y 1/3 (-1 + (-1) r u - u (x + I y)))) / 2 2 2 2 Im[((3 I + Sqrt[3]) r (-1 + u ) ) / 2/3 ((1 + r u + u (x + I y)) (1 + (-1) r u + u (x + I y)) 2/3 Conjugate[r u + (-1) (1 + u (x + I y))] 2/3 (1 + Conjugate[(-1) r u + u (x + I y)]))]], 2/3 2/3 r + (-1) (u + x + I y) 2 (-1 + (-1) ) Abs[-------------------------------] 2/3 2 r u + (-1) (1 + u (x + I y)) 2 Re[(r (-1 + u ) (------------------------------------------------------- + 2/3 (1 + r u + u (x + I y)) (1 + (-1) r u + u (x + I y)) r + u + x + I y 2 I Sqrt[3] Abs[---------------------] 1 + r u + u x + I u y (------------------------------------- - 2/3 1 + (-1) r u + u x + I u y 2/3 1/3 (-1) r + u + x + I y 2 (1 + (-1) ) Abs[-----------------------------] 2/3 1 + (-1) r u + u x + I u y -------------------------------------------------) / 1 + r u + u x + I u y 1/3 (-1 + (-1) r u - u (x + I y)))) / 2 2 2 2 Im[((3 I + Sqrt[3]) r (-1 + u ) ) / 2/3 ((1 + r u + u (x + I y)) (1 + (-1) r u + u (x + I y)) 2/3 Conjugate[r u + (-1) (1 + u (x + I y))] 2/3 (1 + Conjugate[(-1) r u + u (x + I y)]))]]}, 3 2 3 -((6 Sqrt[3] Abs[(r (-1 + u ) ) / 2/3 2 2 ((r u + (-1) (1 + u (x + I y))) (1 + r u + u (x + I y)) 2/3 2 (1 + (-1) r u + u (x + I y)) )]) / 2 2 2 2 Im[((3 I + Sqrt[3]) r (-1 + u ) ) / 2/3 ((1 + r u + u (x + I y)) (1 + (-1) r u + u (x + I y)) 2/3 Conjugate[r u + (-1) (1 + u (x + I y))] 2/3 (1 + Conjugate[(-1) r u + u (x + I y)]))])] (*Method: Circumscribe the transformation of a triangle inscribed in the original circle.*) In[167]:= FullSimplify[ ComplexExpand[List @@ %], -1 < u < 1 && {x, y} \[Element] Reals && r > 0] // tim During evaluation of In[167]:= 184595.531368,2 Out[167]= 2 2 2 x + u (1 - r + x (u + x) + y ) y - u y {{-(-------------------------------), -------------------------------}, 2 2 2 2 2 2 2 2 r u - (1 + u x) - u y 1 + u (2 x + u (-r + x + y )) 2 r (-1 + u ) --------------------------} 2 2 2 2 2 r u - (1 + u x) - u y (*FullSimplify is a heuristic treesearch taking an optional ComplexityFunction whose default is approximately LeafCount.*) (*Attempting to paste the tim printout into a call to Mathematica's somewhat fussy and thuggish units converter resulted in an uneditable expression--it just clunked when I tried modifying most any portion. The "SequenceForm" (??) was completely invisible!*) UnitConvert[SequenceForm[ 184595.53136799999629147350788116455078125`11.286821096829165, ",", 2] (*Trying various alternatives, including a different Mathematica,*) UnitConvert[SequenceForm[ 184595.53136799999629147350788116455078125`11.286821096829165, ",", 2] UnitConvert[184595.531367999996 "seconds", "hours"] Out[169]= UnitConvert[184595.53136800000 "seconds", "hours"] In[172]:= UnitConvert[Quantity[184595.531367999996 , "seconds"], "hours"] Out[172]= Quantity[51.276536491111110, "Hours"] (*In the notebook, this just displays as 51.276536491111110 h !*) In[171]:= UnitConvert[184595.531367999996 "sec", "hr"] Out[171]= UnitConvert[184595.53136800000 "sec", "hr"] --rwg SetAttributes[tim, HoldAll tim[xp_] := Block[{v = AbsoluteTiming[xp]}, Print[v[[1]], ",", Length[v[[2]]]]; If[v[[1]] > 69, Speak[v[[1]]]]; v[[2]]]
participants (1)
-
Bill Gosper