Re: ArcCos[x] with x > 1
- To: mathgroup at smc.vnet.net
- Subject: [mg49322] Re: ArcCos[x] with x > 1
- From: ab_def at prontomail.com (Maxim)
- Date: Wed, 14 Jul 2004 07:29:27 -0400 (EDT)
- References: <cclev9$kb3$1@smc.vnet.net> <cco3io$4ig$1@smc.vnet.net> <cctaff$c11$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Carl K. Woll" <carlw at u.washington.edu> wrote in message news:<cctaff$c11$1 at smc.vnet.net>... > > Unfortunately, I think the use of Integrate for definite integrals may > always have these problems with branches. After all, even if it were > possible to rotate the branch cuts of functions on the fly, it will not > always be possible to orient all of the branch cuts of the functions that > arise in the indefinite integral so that they don't cross the path of > integration. Rotating the branch cuts can be a fruitful idea for handling integrals of rational functions. Here's a quick implementation: In[1]:= ClearAll[int] Options[int] = {Assumptions :> $Assumptions}; int::idiv = "Integral of `1` does not converge on `2`."; int[$fz_, {$z_?(Variables[#] === {#} &), z1_, z2_}, Sopt___?OptionQ] := Module[ {main, assum, ans}, main[] := Module[ {lambdaQ, dummyint, fz = $fz, pz, qz, modz, adz, cond, Lz0, La, z}, lambdaQ = Element[#, Reals] && 0 <= # <= 1 &; If[z1 == z2, Return[0]]; fz = Together[fz /. $z -> z]; {pz, qz} = {Numerator[fz], Denominator[fz]}; If[! PolynomialQ[pz, z] || ! PolynomialQ[qz, z], Return[$Failed] ]; Lz0 = Union@Array[Root[Function @@ {z, qz}, #] &, Exponent[qz, z]]; La = Residue[pz/qz, {z, #}] & /@ Lz0; modz = Together[fz - Total[La/(z - Lz0)]]; adz = Total[La*Log[(z - Lz0)/(z2 - z1)]]; cond = Refine[ z1 != z2 && And @@ (!lambdaQ[(# - z1)/(z2 - z1)] &) /@ Lz0]; If[!cond, Message[int::idiv, $fz, {z1, z2}]; Return[$Failed] ]; If @@ {cond, Integrate[modz, {z, z1, z2}, GenerateConditions -> False] + (adz /. z -> z2) - (adz /. z -> z1), dummyint[$fz, {$z, z1, z2}, Assumptions -> !cond && $Assumptions]} /. dummyint -> int ]; assum = Assumptions /. Flatten@{Sopt, Options[int]}; Block[ {$Assumptions = assum}, ans /; (ans = main[]) =!= $Failed ] ] An example: In[5]:= Assuming[Element[{a, b}, Reals] && a != b, int[1/(z^2 - 1), {z, -2 + I*a, -2 + I*b}] // Simplify] Out[5]= (Log[(I + a)/(-a + b)] - Log[(3*I + a)/(-a + b)] - Log[(I + b)/(-a + b)] + Log[(3*I + b)/(-a + b)])/2 This approach has several advantages: it is fast; it returns relatively simple conditions (compare with Mathematica's output for Integrate[1/(z^2-1),{z,-2+I*a,-2+I*b}], which has a size of 250kb); and most importantly, it gives the complete answer, that is, there is no need to reevaluate the resulting If expression: either the If condition is true or the integral doesn't converge. I wonder whether this method can be extended to handle fractional powers; it certainly would be hard to generalize it to antiderivatives containing nested radicals or logarithms, because the branch cuts aren't necessarily straight lines then. Maxim Rytin m.r at inbox.ru