Lời giải:
Ta có:
\(A=\int \frac{x\sin x+\cos x}{x^2-\cos ^2x}dx=\int \frac{(\cos x-x)+x(\sin x+1)}{x^2-\cos ^2x}dx\)
\(=-\int \frac{dx}{\cos x+x}+\int \frac{x(\sin x+1)}{x^2-\cos ^2x}dx=-\int \frac{dx}{x+\cos x}+\frac{1}{2}\int (\sin x+1)\left(\frac{1}{x-\cos x}+\frac{1}{x+\cos x}\right)dx\)
\(=-\int \frac{dx}{x+\cos x}+\frac{1}{2}\int (\sin x+1)\frac{dx}{x-\cos x}+\frac{1}{2}\int (\sin x-1)\frac{dx}{x+\cos x}+\int \frac{dx}{x+\cos x}\)
\(=\frac{1}{2}\int (\sin x+1)\frac{dx}{x-\cos x}+\frac{1}{2}\int (\sin x-1)\frac{dx}{x+\cos x}\)
\(=\frac{1}{2}\int \frac{d(x-\cos x)}{x-\cos x}+\frac{1}{2}\int \frac{-d(x+\cos x)}{x+\cos x}\)
\(=\frac{1}{2}\ln |x-\cos x|-\frac{1}{2}\ln |x+\cos x|+c\)
Xét biểu thức $B$
\(B=\int \frac{\ln x-1}{x^2-\ln ^2x}dx=\int \frac{(\ln x-x)+(x-1)}{x^2-\ln ^2x}dx\)
\(=-\int \frac{dx}{x+\ln x}+\int \frac{x-1}{x^2-\ln ^2x}dx=-\int \frac{dx}{x+\ln x}+\frac{1}{2}\int \frac{(x-1)}{x}\left(\frac{1}{x-\ln x}+\frac{1}{x+\ln x}\right)dx\)
\(=-\int \frac{dx}{x+\ln x}+\frac{1}{2}\int \frac{1}{x-\ln x}.\frac{x-1}{x}dx+\frac{1}{2}\int \frac{1}{x+\ln x}.\frac{x-1}{x}dx\)
\(=-\int \frac{dx}{x+\ln x}+\frac{1}{2}\int \frac{1}{x-\ln x}.\frac{x-1}{x}dx-\frac{1}{2}\int \frac{1}{x+\ln x}.\frac{1+x}{x}dx+\int \frac{dx}{x+\ln x}\)
\(=\frac{1}{2}\int \frac{1}{x-\ln x}.\frac{x-1}{x}dx-\frac{1}{2}\int \frac{1}{x+\ln x}.\frac{1+x}{x}dx\)
\(=\frac{1}{2}\int \frac{d(x-\ln x)}{x-\ln x}-\frac{1}{2}\int \frac{d(x+\ln x)}{x+\ln x}\)
\(=\frac{1}{2}\ln |x-\ln x|-\frac{1}{2}\ln |x+\ln x|+c\)