Error in simplifying $\frac{\tan x+\sec x-1}{\tan x-\sec x+1}$

Claim: $$\frac{\tan x+\sec x-1}{\tan x-\sec x +1}\equiv(\tan x+\sec x)\,\frac{\cos x-1}{\cos x-1}.$$

Proof:

  1. When $x$ is an odd multiple of $\pi,\;$ LHS $=-1=$ RHS.
  2. Otherwise, $x$ is neither an odd multiple of $\displaystyle\frac\pi2$ (an implicit condition of the identity, due to $\cos x\ne0$) nor an odd multiple of $\pi:$ $$\sqrt2\cos\left(x-\frac\pi4\right)=-1\iff x=(2n-1)\pi\:\text{ or }\:(4n-1) \frac\pi2\\\sqrt2\cos\left(x-\frac\pi4\right)\ne -1\\\sin x+\cos x\ne-1\\\tan x+1\ne-\sec x\\\tan x+\sec x+1\ne0\\\text{LHS}=\frac{\tan x+\sec x-1}{\tan x-\sec x +1}\times\frac{\tan x+\sec x+1}{\tan x+\sec x+1}\\=\frac{\tan^2x+\sec^2x+2\tan x\sec x-1}{\tan^2x+1+2\tan x-\sec^2x}\\=\frac{2\tan^2x+2\tan x\sec x}{2\tan x}\\=(\tan x+\sec x)\,\frac{\tan x}{\tan x}\\=(\tan x+\sec x)\,\frac{\cos x-1}{\cos x-1}=\text{RHS}.$$

(The rightmost fractions in the last two lines are implicit conditions that $x$ is not an even multiple of $\pi.$)


Alternative claim:

When $x$ is not an even multiple of $\pi\,$ (or an odd multiple of $\displaystyle\frac\pi2),$ $$\frac{\tan x+\sec x-1}{\tan x-\sec x +1}\equiv\tan x+\sec x.$$

Proof:

  1. When $x$ is an odd multiple of $\pi,\;$ LHS $=-1=$ RHS.
  2. Otherwise, $x$ is neither a multiple of $\pi$ nor an odd multiple of $\displaystyle\frac\pi2:$ $$\sqrt2\cos\left(x-\frac\pi4\right)=-1\iff x=(2n-1)\pi\:\text{ or }\:(4n-1) \frac\pi2\\\sqrt2\cos\left(x-\frac\pi4\right)\ne -1\\\sin x+\cos x\ne-1\\\tan x+1\ne-\sec x\\\tan x+\sec x+1\ne0\\\text{LHS}=\frac{\tan x+\sec x-1}{\tan x-\sec x +1}\times\frac{\tan x+\sec x+1}{\tan x+\sec x+1}\\=\frac{\tan^2x+\sec^2x+2\tan x\sec x-1}{\tan^2x+1+2\tan x-\sec^2x}\\=\frac{2\tan^2x+2\tan x\sec x}{2\tan x}\\=(\tan x+\sec x)\,\frac{\tan x}{\tan x}\\=\tan x+\sec x=\text{RHS}.$$