Ask Your Question
0

Issues with numerically integrating a complex value function. Any way of getting around the 'Unable to convert 5.0 + 1.0*I to float; use abs() or real_part() as desired' error?

asked 2015-07-08 22:04:49 +0100

x = var('x') a = 5.0 + I
b = 3.0 + I
numerical_integral((1/sqrt(x^3 + a*x + b)).real(), 0, 3)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-07-09 00:08:49 +0100

tmonteil gravatar image

updated 2015-07-09 00:10:17 +0100

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)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-07-08 22:04:49 +0100

Seen: 634 times

Last updated: Jul 09 '15