Here's a speed comparison, assuming the initialization of System`TrigToRadicalsDump`cos has been done. (* 263365 <- in terms of (real) radicals takes only 0.06s *) System`TrigToRadicalsDump`cos // AbsoluteTiming Simplify`TrigToRealRadicals (* load/initialize *) The second, I retested with a fresh kernel and got the above, which confused me for a while. The first time I tested, it had been loaded and I got results like those below. I cannot say for certain what functions cause the loading of the package. If the trig-to-radicals functionality has been loaded, then we get a different behavior. At first, FunctionExpand does nothing, and ToRadicals returns the simplified expansion in terms of the complex exponential function. However, the timings below show that FunctionExpand does a lot of unnecessary work. These function memoize their results, which makes timing them a challenge. It in turn calls a function like System`TrigToRadicalsDump`tan, which computes the conversion. The internal function that does what the OP wants is called Simplify`TrigToRealRadicals, which is called by FunctionExpand and ToRadicals in this case. Mathematica and The Wolfram Language are now available from ours and the Raspberry Pi foundation's software repositories for the default Raspbian Linux distribution for the Pi. ![]() An answer to How does Mathematica calculate $\sin(\pi/5)$? by points out that in the Notes on Internal Implementation, it is implied that FunctionExpand is the way to expand trigonometric functions in terms of radicals when possible:įunctionExpand uses an extension of Gauss's algorithm to expand trigonometric functions with arguments that are rational multiples of π.
0 Comments
Leave a Reply. |