Finding roots of complex functions

i like this post (click again to cancel)
1
i dont like this post (click again to cancel)

This could be a Maxima question as it relates to find_root, find_minimum_on_interval, etc.

When I try to find the root of a function involving I (complex numbers) I get:

TypeError: float() argument must be a string or a number

For example, find_root(abs(1-exp(I*x)),-1,1).

asked Mar 13 '11

David Ferrone gravatar image David Ferrone
131 3 5 11

2 Answers:

i like this answer (click again to cancel)
2
i dont like this answer (click again to cancel) David Ferrone has selected this answer as correct

One way to get around this is to define the real and imaginary parts of the function and find roots of the sum of their squares:

sage: x = var('x')
sage: f = 1 - exp(I*x)
sage: fr = real_part(f)
sage: fi = imag_part(f)
sage: find_root(fr^2 + fi^2, -1, 1)
0.0

Calling full_simplify() on f = abs(1- exp(I*x)) returns a multiply of I which is clearly a real number (if x is a real number), but I don't know how to coax maxima or Sage into converting f into a explicitly real function of a real variable.

link

posted Mar 13 '11

benjaminfjones gravatar image benjaminfjones
2470 3 33 66
http://bfj7.com/
i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

There are a couple of ways to get around this:

sage: find_root(lambda x: RR(abs(1-exp(I*x))),-1,1)
5.5511151231257827e-17

sage: find_root(simplify(abs(1-exp(I*x))),-1,1)
5.5511151231257827e-17

Under the hood this is becoming sqrt((cos(x) - 1)^2 + sin(x)^2).

But I think this should work:

sage: RR(abs(exp(x*I)).subs(x=2))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[...]
/Applications/sage/local/lib/python2.6/site-packages/sage/rings/number_field/number_field_element.so in     sage.rings.number_field.number_field_element.NumberFieldElement._mpfr_ (sage/rings/number_field/number_field_element.cpp:8541)()

TypeError: cannot convert 2*I to real number

You shouldn't need each expression operand to be real to convert to a real.

link

posted Mar 13 '11

DSM gravatar image DSM flag of Canada
4802 12 61 103
Yeah, this is a long-standing problem, which unfortunately we've never had the energy to sort through in all cases. Help is welcome - there may be more than one ticket about this. kcrisman (Mar 14 '11)

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Tags:

Stats:

Asked: Mar 13 '11

Seen: 459 times

Last updated: Mar 13 '11

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.