integrate? sign?



 On 2013-05-25, Richard Fateman  wrote:
integrate(sqrt(tan(x)^2 + 2 * tan(x) + 2),x);
sign: argument cannot be imaginary; found %i
  -- an error. To debug this try: debugmode(true);

 A similar problem is obtained in
(%i1) S:'integrate(sqrt(2+tan(x)^2),x);
(%o1) integrate(sqrt(tan(x)^2+2),x)
(%i2) ev(%, nouns);
sign: argument cannot be imaginary; found %i
 -- an error. To debug this try: debugmode(true);

 Solution by step-by-step:
(%i3) tr:x=atan((t^2-2)/(2*t));
(%o3) x=atan((t^2-2)/(2*t))
(%i4) itr:solve(tr,t)[2];
(%o4) t=sqrt(tan(x)^2+2)+tan(x)
(%i5) assume(t>0)$
(%i6) changevar(S, tr,t,x);
(%o6) integrate((t^4+4*t^2+4)/(t^5+4*t),t)
(%i7) subst(first(%)=ratsimp(first(%)-1/t)+1/t,%);
(%o7) integrate((4*t)/(t^4+4)+1/t,t)
(%i8) ev(%, nouns);
(%o8) atan(t^2/2)+log(t)

 Solution:
(%i9) sol:subst(itr,%);
(%o9) atan((sqrt(tan(x)^2+2)+tan(x))^2/2)+log(sqrt(tan(x)^2+2)+tan(x))

 Test:
(%i10) trigsimp(diff(sol,x)-sqrt(2+tan(x)^2));
(%o10) 0

Compare with WolframAlpha Step-by-step Solution.

 best

Aleksas Domarkas