For varying values of n, I'd like to find values of a so that int_0^z 
(x-a)^n dx has a root on the unit circle.

As I'd like high precision, mpmath seems right.

I can set things up as follows:

sage: from mpmath import *; mp.dps=30; mp.pretty=true
sage: var("a b c", domain="real")
sage: p=integral((x-a)^2, x)
sage: print p.subs(x=b+c*I).real()
sage: print p.subs(x=b+c*I).imag()
a^2*b - a*b^2 + a*c^2 + 1/3*b^3 - b*c^2
a^2*c - 2*a*b*c + b^2*c - 1/3*c^3

and then copy-and-paste the equations into a function
and solve:

sage: def f(a, b, c):
...       return (a^2*b - a*b^2 + a*c^2 + 1/3*b^3 - b*c^2,
...               a^2*c - 2*a*b*c + b^2*c - 1/3*c^3,
...               b^2+c^2-1 )
...          
sage: findroot(f, (0.57, 0.85, 0.49))
...       
[0.577350269189625764509148780502]
[0.866025403784438646763723170753]
[                             0.5]

which works, but I need to eliminate the manual copy-and-paste.

What can I do to avoid the following error?

sage: def g(a, b, c):
...       return (p.subs(x=b+c*I).real(),
...               p.subs(x=b+c*I).imag(),
...               b^2+c^2-1 )
...          
sage: findroot(g, (0.57, 0.85, 0.49))
Traceback (most recent call last):
...
TypeError: g() takes exactly 3 arguments (1 given)

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to