Author: Bill Page
Views : 49
Description: prettier versioin of integral.sagews
Compute Environment: Ubuntu 18.04 (Deprecated)

###Bug in Sage Integral Computations?###

# Better version of FriCAS mode for SageMathCloud
os.environ['PATH'] = '%s/bin:%s'%(os.environ['HOME'],os.environ['PATH'])
from fricas import fricas
execfile('fricas_md.py')
%default_mode fricas_md

)version
)clear completely
)set output tex on
)set output algebra off


Value = "FriCAS 2014-12-18 compiled at Tue May 5 18:13:01 UTC 2015"

All user variables and function definitions have been cleared.

All )browse facility databases have been cleared.

Internally cached functions and constructors have been cleared.

)clear completely is finished.




FriCAS agrees with Sage that the value of the integral is 0.

ex:=sqrt( cot(x)^2 )


$$\sqrt {{{{\cot \left( {x} \right)}} ^{2}}}$$

Type: Expression(Integer)

i1:=integrate(ex, x = %pi/4 .. 3*%pi/4,"noPole")


$$0$$

Type: Union(f1: OrderedCompletion(Expression(Integer)),...)

%sage
typeset_mode(true)
s1=integrate(sqrt( cot(x)^2 ), x,pi/4,3*pi/4);s1

$0$

Consider the indefinite integral

i2:=integrate(ex, x)


$${{2 \ {\log \left( {{{\sin \left( {{2 \ x}} \right)} \over {{\cos \left( {{2 \ x}} \right)}+1}}} \right)}} -{\log \left( {{2 \over {{\cos \left( {{2 \ x}} \right)}+1}}} \right)}} \over 2$$

Type: Union(Expression(Integer),...)

%sage s2=fricas('i2::Expression Integer').sage();s2

$\log\left(\frac{\sin\left(2 \, x\right)}{\cos\left(2 \, x\right) + 1}\right) - \frac{1}{2} \, \log\left(\frac{2}{\cos\left(2 \, x\right) + 1}\right)$
%sage plot(s2,x,pi/4,2*pi/4) There is a pole at $\pi/2$ and the branch becomes complex after that point.

eval(i2,x=2*%pi/4-0.0001)


$$-{0.4999955155 E -8}$$

Type: Expression(Float)

eval(i2,x=3*%pi/4)


$${-{\log \left( {2} \right)}+{2 \ {\log \left( {-1} \right)}}} \over 2$$

Type: Expression(Integer)

complexNumeric %


$$-{0.3465735902_7997265471}+{{3.1415926535_897932385} \ i}$$

Type: Complex(Float)

Both $\sqrt \$ and $\log(x)$ for $x<0$ are "multi-valued functions". In the case of log, the branches for negative numbers differ by $i\pi$, so we can choose a branch that is real-valued.

i3:=i2-%pi*%i


$${{2 \ {\log \left( {{{\sin \left( {{2 \ x}} \right)} \over {{\cos \left( {{2 \ x}} \right)}+1}}} \right)}} -{\log \left( {{2 \over {{\cos \left( {{2 \ x}} \right)}+1}}} \right)} -{2 \ i \ \pi}} \over 2$$

Type: Expression(Complex(Integer))

eval(i3,x=3*%pi/4)


$${-{\log \left( {2} \right)}+{2 \ {\log \left( {-1} \right)}} -{2 \ i \ \pi}} \over 2$$

Type: Expression(Complex(Integer))

complexNumeric %


$$-{0.3465735902_7997265471}$$

Type: Complex(Float)

%sage s3=fricas('i2::Expression Integer').sage()-pi*i;s3

$-i \, \pi + \log\left(\frac{\sin\left(2 \, x\right)}{\cos\left(2 \, x\right) + 1}\right) - \frac{1}{2} \, \log\left(\frac{2}{\cos\left(2 \, x\right) + 1}\right)$
%sage s3.substitute(x=3*pi/4)

$-\frac{1}{2} \, \log\left(2\right)$
%sage
def ss(x0):
return s3.substitute(x=x0).N()

%sage ss(2*pi/4+0.0001)

-3.62865471004170e-9
%sage plot(ss,2*pi/4+0.0001,3*pi/4) We expect the derivative of the indefinite integral to be equal to the original expression.

d1:=differentiate(i2,x)


$${{{{\sin \left( {{2 \ x}} \right)}} ^{2}}+{2 \ {{{\cos \left( {{2 \ x}} \right)}} ^{2}}}+{2 \ {\cos \left( {{2 \ x}} \right)}}} \over {{\left( {\cos \left( {{2 \ x}} \right)}+1 \right)} \ {\sin \left( {{2 \ x}} \right)}}$$

Type: Expression(Integer)

In FriCAS normalize rewites an expression "using the least possible number of algebraically independent kernels".

normalize(ex-d1)


$$0$$

Type: Expression(Integer)

%sage s2=integrate( sqrt( cot(x)^2 ), x); s2

$-\frac{1}{2} \, \log\left(\tan\left(x\right)^{2} + 1\right) + \log\left(\tan\left(x\right)\right)$
%sage (fricas(s2)-fricas('i2')).normalize().sage()

$0$

The conclusion is that although these results are not identical they are nonetheless algebraically dependent.