# Discrepancy between Mathematica integral and Wikipedia

I tried to Integrate

Integrate[Sech[h], h]


I got

2 ArcTan[Tanh[h/2]]


I tried to simplify it

Simplify[%]


I got the same result. But Wikipedia has $$\arctan(\sinh(h))$$.

What am I doing wrong?

• Short answer: Nothing (as in, "You did nothing wrong"). Would that it were always so simple... – Daniel Lichtblau Jul 15 '18 at 15:00
• FWIW the Tanh[h/2] makes me think the hyperbolic version of the Weierstrass substitution is being used. This is a method that can be applied to many hyperbolic trig expressions, so it makes sense (to me at least) that it’s used here. – Chip Hurst Jul 15 '18 at 20:20
• Did any of the answers satisfied your need? There are things to do after your question is answered. It's a good idea to stay vigilant for some time, better approaches may come later improving over previous replies. Experienced users may point alternatives, caveats or limitations. New users should test answers before voting and wait 24 hours before accepting the best one. One weeks is enough wait. Participation is essential for the site, please do your part. – rhermans Jul 22 '18 at 9:45

## 6 Answers

The results shown in integral tables are those that human mathematicians have judged, subjectively, to be the optimum forms, i.e., the simplest and/or most intuitive way to present each result. Mathematica's results will sometimes correspond to these forms, and sometimes not (but the two will be mathematically equivalent [within an integration constant, as noted in Bob Hanlon's comment], unless there's a bug in Mathematica, an error in the integral table, or the two have different domain restrictions on the parameters or variables).

If you are interested in obtaining integrals whose forms are designed to correspond, as closely as possible, to the forms chosen for integral tables, you might wish to consider downloading Rubi, an integration package for Mathematica (http://www.apmaths.uwo.ca/~arich/). For instance, using Rubi:

Int[Sech[h], h]


ArcTan[Sinh[h]]

The identity can be obtained as follows.

ForAll[h, ArcTan[Sinh[h]] - 2 ArcTan[Tanh[h/2]] == 0];
Resolve[%, Reals]


True

• Is there any way I could have gotten the expression ArcTan[Sinh[h]] without knowing it in advance? – Gene Naden Jul 15 '18 at 8:01
• @Gene Naden: Good question! Don't know it. – user64494 Jul 15 '18 at 8:41
• @GeneNaden RUBI gives that answer (but keep in mind that getting the "simplest" form is more involved than "basic" expression simplification due to the additive constant Bob mentioned). Also, I suspect that RUBI may have this answer effectively pre-coded. – Szabolcs Jul 16 '18 at 15:44

For your example, there was a rather easy transformation from the expression returned by Mathematica and the expression you were looking for (see the other answers). I would advice you to check the plausibility of those two expressions being equivalent before you try to prove they are equivalent. I would do

Plot[2 ArcTan[Tanh[h/2]] - ArcTan[Sinh[h]], {h, -10, 10}]


From the graph, you can infer that "it is plausible that those two expressions are equivalent". Rounding error and differences outside the plotted range might still exist.

THIS IS AN EXTENDED COMMENT RATHER THAN AN ANSWER.

Although in the case that you sited, the indefinite integrals are equal; there is no reason to think that that must be the case. Indefinite integrals can differ by an arbitrary constant of integration. For example,

Clear[int1, int2]

int1[h_] = Integrate[Sech[h], h]

(* 2 ArcTan[Tanh[h/2]] *)

int2[h_] = Integrate[Sech[h] // TrigToExp, h] // ExpToTrig // FullSimplify

(* 2 ArcTan[E^h] *)


These two seemingly equivalent indefinite integrals differ by

Series[int2[h], {h, 0, 100}] - Series[int1[h], {h, 0, 100}] // Normal

(* π/2 *)


Consequently,

(int2[h] - int1[h] - Pi/2 == 0 //
ComplexExpand[#, TargetFunctions -> {Re, Im}] & // FullSimplify)

(* 2 ArcTan[Tanh[h/2]] == Gudermannian[h] *)


So int1[h] is equal to Gudermannian[h]

Gudermannian[h] // FunctionExpand

(* -(π/2) + 2 ArcTan[E^h] *)


And Gudermannian[h] differs from int2[h] by Pi/2

Plot[{int1[h], int2[h] - Pi/2, Gudermannian[h]}, {h, -5, 5},
PlotStyle -> {AbsoluteDashing[{15, 10}], {Thick, Dotted}, DotDashed},
PlotLegends -> Placed["Expressions", {0.25, 0.75}]] D[int1[h], h] == D[int2[h], h] == D[Gudermannian[h], h]== D[ArcTan[Sinh[h]], h] ==
Sech[h] // Simplify

(* True *)


The two answers are identical. That follows from

2 ArcTan[Tanh[h/2]]-ArcTan[Sinh[h]] /. h->0
(* 0 *)


and

2 ArcTan[Tanh[h/2]]-ArcTan[Sinh[h]] //Tan //FullSimplify
(* 0 *)


Just to add to the answers already given: we have the identity

$$\arctan\left(\frac{2z}{1-z^2}\right)=2\arctan z,\quad |z|<1$$

Since $$\tanh z$$ is within $$(-1,1)$$ for real $$z$$, we then have

2 ArcTan[Tanh[h/2]] /. ArcTan[u_] :> ArcTan[2 u/(1 - u^2)]/2 // Simplify
ArcTan[Sinh[h]]


which was the expected answer.