enhanced ArcCos[] ?
- To: mathgroup at smc.vnet.net
- Subject: [mg24805] enhanced ArcCos[] ?
- From: Gianluca Gorni <gorni at dimi.uniud.it>
- Date: Sun, 13 Aug 2000 03:16:43 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Andrzej!
By the way, I didn't send my numeric workaround to the
mathgroup.
A few ideas about how to enhance ArcCos[]: here is an
attempt of mine, using numerics as intermediate steps:
myArcCos[x_ /; Element[x, Algebraics]] :=
Module[{prec = 10^(-5), attempt},
attempt = Rationalize[ArcCos[x]/Pi // N, prec];
If[Chop[N[Cos[attempt*Pi] - x]] === 0 &&
FullSimplify[FunctionExpand[Cos[attempt*Pi]] - x] === 0,
attempt*Pi,
ArcCos[x]]];
(We need "prec" because of a bug in Rationalize[] in Mathematica 4).
It seems to work for cosines of simple fractions of Pi.
This solution is so cheap that I think wri should do
something about the problem. After all, one of the novelties of
Mathematica 4 (or was it 3?) was FunctionExpand, that gave radicals expressions
for direct trig function. I was disappointed to see that
it does not do the reverse. I think FunctionExpand should
cover inverse trig functions.
Of course an experienced mathematica programmer will find
a workaround if he/she needs it. What I have in mind is
a beginner.
Since all cyclotomic polynomials up to n=104
have +1, 0 and -1 as the only coefficients, a
preliminary easy (?) test for an algebraic number to be
the cosine of a rational multiple of Pi may be something
like this
prelTest[x_ /; Element[x, Algebraics]] :=
Module[{minPol, coe},
minPol = RootReduce[x + I*Sqrt[1 - x^2]][[1, 1]];
coe = CoefficientList[minPol, #1];
If[Degree[minPol, #1] < 105 &&
Complement[coe, {1, -1, 0}] =!= {}, False,
True]]
I wonder if it would take a long time to develop
these ideas into an enhanced FunctionExpand that gave
sensible inverse trig function results reasonably quickly.
Best regards,
Gianluca Gorni