Group Abstract Group Abstract

Message Boards Message Boards

1
|
7.8K Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Healthy variety in Mathematica calculus

Posted 10 years ago

Take three definitions of the same function ArcTan[Tan[k]]. Can these be integrated? Can their integrals be differentiated?

sf[1, k_] := ArcTan[Tan[k]];
sf[2, k_] := Mod[k + \[Pi]/2, \[Pi]] - \[Pi]/2
sf[3, k_] := \[Pi] SawtoothWave[k/\[Pi] - 1/2] - \[Pi]/2

Equivalence plot

The integrals Mathematica computes take varied form. Sawtooth[] does not integrate, which is fine.

Integral forms

The other two look quite distinct, a plot comparison confirms.

Integral plots

It appears that the Mod form of the equation is the cleanest to work with, the trigonometric integral clearly being erroneous. Differentiating these integrals we hope to return to the original equation.

Derivative of integral plots

It is now the Mod form that produces odd results.

It seems no form of ArcTan[Tan[k]] is suitable for automatic calculus; stemming presumably from tricky issues with regular discontinuity. It's concerning that so many of these procedures fail silently. If I integrate similar functions unexpectedly in the body of a volume of work, I likely wont observe these complications.

This exploration was prompted by @Marco Thiel's work computing a convergent integral here.

Attachments:
POSTED BY: David Gathercole
2 Replies

Interestingly your 'k non-negative' assumptions (which at first glance appear redundant) make all the difference. Asserting k is real also works here. Unfortunately similar assumptions I've tried do not recover the derivative.

comparison plots

POSTED BY: David Gathercole

The original code is probably fine but there is some confusing (to me) usage of x vs. k, possibly to emulate an indefinite integral. I made a few changes both to separate these uses and to give the definite integrals a fighting chance by understanding they are integrating along the positive real axis.

 sf[1, x_] := ArcTan[Tan[x]]
sf[2, x_] := Mod[x + \[Pi]/2, \[Pi]] - \[Pi]/2
sf[3, x_] := \[Pi] SawtoothWave[x/\[Pi] - 1/2] - \[Pi]/2

ci[1, k_] = Integrate[sf[1, x], {x, 0, k}, Assumptions -> k > 0]

(* ConditionalExpression[
 Piecewise[{{(1/2)*Pi^2*FractionalPart[k/Pi]^2, -(1/2) < 
     FractionalPart[k/Pi] < 1/2}}, 
     (-(1/2))*
   Pi*(-Pi - 2*ArcTan[Tan[k]]*FractionalPart[k/Pi] + 
     Pi*FractionalPart[k/Pi]^2)], 2*k >= Pi] *)

ci[2, k_] = Integrate[sf[2, x], {x, 0, k}, Assumptions -> k > 0]

(* -((k*Pi)/2) + (1/2)*Pi^2*IntegerPart[k/Pi] + 
 Piecewise[{{-(Pi^2/8), FractionalPart[k/Pi] == 0}, 
       {(1/2)*
     Pi^2*(1 - FractionalPart[k/Pi] + FractionalPart[k/Pi]^2), 
    2*FractionalPart[k/Pi] > 1}}, 
     (1/2)*Pi^2*FractionalPart[k/Pi]*(1 + FractionalPart[k/Pi])] *)

ci[3, k_] = Integrate[sf[3, x], {x, 0, k}, Assumptions -> k > 0]

(* Out[869]= Integrate[-([Pi]/ 2) + [Pi] SawtoothWave[1/2 + x/[Pi]], {x, 0, k}, Assumptions -> k > 0] *)

(Two out of three ain't bad, as a song famously put it.)

Let's do some numeric checks.

In[870]:= ci[1, 5.5]

Out[870]= 0.30669

In[871]:= ci[2, 5.5]

Out[871]= 0.30669

In[872]:= ci[3, 5.5]

Out[872]= 0.30669

In[873]:= NIntegrate[sf[1, x], {x, 0, 5.5}]

Out[873]= 0.305746
POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard