Opened 12 years ago

Closed 12 years ago

#10088 closed defect (fixed)

numerical_integral fails for constant expressions

Reported by: Luis Felipe Tabera Alonso Owned by: jason, jkantor
Priority: major Milestone: sage-4.7
Component: numerical Keywords: numerical_integral
Cc: Merged in: sage-4.7.alpha2
Authors: Douglas McNeil Reviewers: Luis Felipe Tabera Alonso
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

numerical_integral fails for constant expressions

sage: f = x
sage: g = x-1
sage: numerical_integral(f,-2,2)
(0.0, 4.4389290910485955e-14)
sage: numerical_integral(g,-2,2)
(-4.0, 5.550866604629029e-14)
sage: numerical_integral(f+g, -2, 2)
(-4.0, 9.4350890128471666e-14)
sage: numerical_integral(f-g, -2, 2)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/home/luisfe/Varios/quotes/intradia/<ipython console> in <module>()

/opt/SAGE/sage-4.5.2/local/lib/python2.6/site-packages/sage/gsl/integration.so in sage.gsl.integration.numerical_integral (sage/gsl/integration.c:1551)()

ValueError: Integrand has wrong number of parameters

sage: type(f-g)
<type 'sage.symbolic.expression.Expression'>
sage: f-g
1

Attachments (1)

trac_10088_constant_expressions_numerical_integral.patch (1.4 KB) - added by D.S. McNeil 12 years ago.
allow constant (i.e. variable-free) symbolic expressions in numerical_integral

Download all attachments as: .zip

Change History (7)

comment:1 Changed 12 years ago by Luis Felipe Tabera Alonso

Summary: numerical_integral fails for xonstant expressionsnumerical_integral fails for constant expressions

comment:2 Changed 12 years ago by D.S. McNeil

The patch simply reuses the existing constant-case line in the symbolic expression branch.

comment:3 Changed 12 years ago by Luis Felipe Tabera Alonso

Milestone: sage-4.6.2sage-4.7

Is it ready for review? The patch looks right, I will check it.

comment:4 Changed 12 years ago by D.S. McNeil

Status: newneeds_review

Changed 12 years ago by D.S. McNeil

allow constant (i.e. variable-free) symbolic expressions in numerical_integral

comment:5 Changed 12 years ago by Luis Felipe Tabera Alonso

Authors: Douglas McNeil
Reviewers: Luis Felipe Tabera Alonso
Status: needs_reviewpositive_review

The patch solves the problem as expected.

comment:6 Changed 12 years ago by Jeroen Demeyer

Merged in: sage-4.7.alpha2
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.