Ask Your Question

lg's profile - activity

2021-08-29 23:35:35 +0200 received badge  Popular Question (source)
2017-10-10 22:15:46 +0200 asked a question an integral with arccos wrong

The value of the integral integrate(exp(arccos(x)),x,0,1) is badly return by Sage. However, sympy_integrator or giac_integrator give the exact value (and also the primitive), maxima giving the same wrong value than Sage (the both unable to give a primitive)

 sage: integrate(exp(arccos(x)),x,0,1)
-1/2*e^(-1/2*pi) + 1/2

Calculus gives through the change of variable x=cos t the equality

\int_0^1 exp(arccos(x))dx= \int_0^{pi/2}e^t sin(t)dt
and the second integral is easily computed :

sage: integrate(exp(t)*sin(t),t,0,pi/2)                          
1/2*e^(1/2*pi) + 1/2 


from sage.symbolic.integration.external import sympy_integrator
sympy_integrator(exp(arccos(x)), x, 0, 1)
1/2*e^(1/2*pi) + 1/2
# GOOD

from sage.symbolic.integration.external import maxima_integrator
maxima_integrator(exp(arccos(x)), x, 0, 1)
-1/2*e^(-1/2*pi) + 1/2
# BAD

from sage.symbolic.integration.external import giac_integrator
giac_integrator(exp(arccos(x)), x, 0, 1)
1/2*e^(1/2*pi) + 1/2
# GOOD
2017-10-10 22:12:10 +0200 asked a question an integral with arccos wrongly evaluated

The value of the integral integrate(exp(arccos(x)),x,0,1) is badly return by Sage. However, sympy_integrator or giac_integrator give the exact value (and also the primitive), maxima giving the same wrong value than Sage

 sage: integrate(exp(arccos(x)),x,0,1)
-1/2*e^(-1/2*pi) + 1/2

Calculus gives through the change of variable x=cos t the equality

\int_0^1 exp(arccos(x))dx= \int_0^{pi/2}e^t sin(t)dt
and the second integral is easily computed. A primitive is also given by sympy and giac, but nothing by sage, nor maxima

from sage.symbolic.integration.external import sympy_integrator
sympy_integrator(exp(arccos(x)), x, 0, 1)
1/2*e^(1/2*pi) + 1/2
# GOOD

from sage.symbolic.integration.external import maxima_integrator
maxima_integrator(exp(arccos(x)), x, 0, 1)
-1/2*e^(-1/2*pi) + 1/2
# BAD

from sage.symbolic.integration.external import giac_integrator
giac_integrator(exp(arccos(x)), x, 0, 1)
1/2*e^(1/2*pi) + 1/2
# GOOD
2017-10-01 12:06:10 +0200 commented answer t_span in ode_solver

Thanks for explanations !

In fact, I was also puzzled by the ode_solver feature giving solution only for positive times : t_1>t_0 if t_span=t_0,t_1] (for negative times (t_1<t_0) ,="" consider="" the="" ode="" y'="-F(-t,y)).&lt;/p">

2017-10-01 12:03:55 +0200 received badge  Editor (source)
2017-09-30 19:27:30 +0200 received badge  Student (source)
2017-09-30 19:24:58 +0200 asked a question t_span in ode_solver

The definition of the first time in t_span has no effect : [t_0,t_1] has the same effect than [0,t_1]. See the code below.

What to do ?


def f(t,y): return[y[0],y[1]]
T = ode_solver()
T.function=f
T.ode_solve(y_0=[1,1],t_span=[-1,0.5],num_points=100)
sx=[j[1][0] for j in T.solution]
sy=[j[1][1] for j in T.solution]
p=line(zip(sx,sy))
p.show(xmin=-3,xmax=3,ymax=3,ymin=-3)
2017-09-04 22:31:00 +0200 received badge  Popular Question (source)
2015-05-15 08:49:41 +0200 commented answer hyphen in subscript

It doesn't work in my full text : [dis]appearance of the hyphen subscript seems to be at random !

2013-02-22 07:45:47 +0200 received badge  Taxonomist
2012-03-11 13:18:22 +0200 asked a question contour and function definition

Hello

Let us consider this piece of code


var('x,y')
px=(x,-1,1)
py=(y,-1,1)

def V(x,y) :
   if (x2+y2 <1) :
     return(x+y+(abs(1-x2-y2))(1/2))
   else:
     return(20)
W(x,y)=x+y+(abs(1-x
2-y2))(1/2)

r=Graphics()
r+=contour_plot(W(x,y),px,py,contours=[1.70],fill=false,cmap=["red"])
r+=contour_plot(V(x,y),px,py,contours=[1.50],fill=false,cmap=["magenta"])
plot(r)


In 4.7, the level lines in magenta and red are displayed, but in 4.8 only the red one appears.

  • is this change expected ?
  • how to let sage knowing the definition of the V function ?