Ask Your Question

Revision history [back]

When you write 1/sqrt(x^3 + a*x + b), you define a symbolic function. In particular:

sage: (1/sqrt(x^3 + a*x + b)).real()
cos(-1/2*arctan2(-imag_part(x)^3 + 3*imag_part(x)*real_part(x)^2 + 5.00000000000000*imag_part(x) + 1.00000000000000*real_part(x) + 1.00000000000000, -3*imag_part(x)^2*real_part(x) + real_part(x)^3 - 1.00000000000000*imag_part(x) + 5.00000000000000*real_part(x) + 3.00000000000000))/sqrt(abs(x^3 + (5.00000000000000 + 1.00000000000000*I)*x + 3.00000000000000 + 1.00000000000000*I))

Since you are looking for numerical integral, you should instead define a Python function:

sage: f = lambda x : (1/sqrt(x^3 + a*x + b)).real_part()
sage: numerical_integral(f, 0, 3)
(0.8675472324763669, 9.631709124450959e-15)

When you write 1/sqrt(x^3 + a*x + b), you define a symbolic function. In particular:

sage: (1/sqrt(x^3 + a*x + b)).real()
cos(-1/2*arctan2(-imag_part(x)^3 + 3*imag_part(x)*real_part(x)^2 + 5.00000000000000*imag_part(x) + 1.00000000000000*real_part(x) + 1.00000000000000, -3*imag_part(x)^2*real_part(x) + real_part(x)^3 - 1.00000000000000*imag_part(x) + 5.00000000000000*real_part(x) + 3.00000000000000))/sqrt(abs(x^3 + (5.00000000000000 + 1.00000000000000*I)*x + 3.00000000000000 + 1.00000000000000*I))

Since you are looking for numerical integral, you should instead define a Python function:

sage: f = lambda x : (1/sqrt(x^3 + a*x + b)).real_part()
sage: numerical_integral(f, 0, 3)
(0.8675472324763669, 9.631709124450959e-15)