On this page
Most trig integrals in Class 12 come from running a known derivative backwards. Sec x and cosec x need one clever step instead. The NCERT Class 12 Mathematics Part II chapter on Integrals (page 238 in the 2026-27 reprint) handles both with the same move. Here is that move, the other forms you will meet in reference books and answer keys, and a quick check that tells you whether your answer is right.
Throughout, log means the natural logarithm (ln), as in NCERT.
How do you integrate sec x?
You need two derivatives: d/dx (sec x) = sec x tan x and d/dx (tan x) = sec²x. If those feel shaky, our walk-through of the derivatives of sec x, cosec x and cot x by the quotient rule rebuilds them.
Multiply top and bottom by (sec x + tan x): ∫sec x dx = ∫ sec x (sec x + tan x) / (sec x + tan x) dx.
Expand the top: sec²x + sec x tan x.
Notice that the top is exactly the derivative of the bottom. Put t = sec x + tan x, so dt = (sec x tan x + sec²x) dx.
The integral becomes ∫dt/t = log|t| + C = log|sec x + tan x| + C.
The trick works because the derivative of sec x + tan x is sec x times sec x + tan x itself.
The result was not always obvious. According to the history summarised on Wikipedia's page on the integral of the secant, which draws on Rickey and Tuchinsky's 1980 article in Mathematics Magazine, Edward Wright evaluated this integral numerically in 1599 to construct an accurate Mercator map projection. In the 1640s Henry Bond compared Wright's table of values with a table of logarithms of tangents and conjectured the formula, and James Gregory proved it in 1668.
How do you integrate cosec x?
Use the matching factor, (cosec x + cot x). Since d/dx (cosec x) = −cosec x cot x and d/dx (cot x) = −cosec²x, the new top, cosec²x + cosec x cot x, is minus the derivative of the bottom. So ∫cosec x dx = −log|cosec x + cot x| + C.
Now tidy it. Because cosec²x − cot²x = 1, the product (cosec x + cot x)(cosec x − cot x) equals 1, so −log|cosec x + cot x| = log|cosec x − cot x|. That gives the NCERT form, ∫cosec x dx = log|cosec x − cot x| + C.
Why do some books write log|tan(π/4 + x/2)|?
It is the same function in half-angle form. Write sec x + tan x = (1 + sin x)/cos x. With t = tan(x/2), sin x = 2t/(1 + t²) and cos x = (1 − t²)/(1 + t²); our post on the tan half-angle substitution derives these. Then:
(1 + sin x)/cos x = (1 + t)²/((1 − t)(1 + t)) = (1 + t)/(1 − t).
Since tan(π/4) = 1, the tan addition formula gives (1 + t)/(1 − t) = tan(π/4 + x/2).
So ∫sec x dx = log|tan(π/4 + x/2)| + C, the log-tangent form Bond spotted.
For cosec, cosec x − cot x = (1 − cos x)/sin x = 2sin²(x/2)/(2 sin(x/2) cos(x/2)) = tan(x/2). So ∫cosec x dx = log|tan(x/2)| + C.
Test it with numbers at x = π/3. Sec x + tan x = 2 + √3, and tan 75° is also 2 + √3. Cosec x − cot x = 2/√3 − 1/√3 = 1/√3, which is tan 30°.
These forms are equal for every x, so they share the same C. When two answers differ by a constant instead, both can still be right, as our piece on why two answers to an integral can look different explains.
How do you check each answer by differentiating?
Differentiate your answer and see whether the integrand comes back. All four forms pass:
d/dx log|sec x + tan x| = (sec x tan x + sec²x)/(sec x + tan x) = sec x.
d/dx log|tan(π/4 + x/2)| = ½ sec²(π/4 + x/2)/tan(π/4 + x/2) = 1/(2 sin(π/4 + x/2) cos(π/4 + x/2)) = 1/sin(π/2 + x) = 1/cos x = sec x.
d/dx log|tan(x/2)| = ½ sec²(x/2)/tan(x/2) = 1/(2 sin(x/2) cos(x/2)) = 1/sin x = cosec x.
d/dx log|cosec x − cot x| = (−cosec x cot x + cosec²x)/(cosec x − cot x) = cosec x.
If a check fails and you cannot find where, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer. If the gap is further back, in the trig derivatives or log rules, the Fermi Concept Library gives each concept in mathematics its own lesson.
Try it now: integrate sec 2x and cosec 3x, then differentiate both answers to see whether you get the integrands back.



