Oops, "243" in my post should have been "k". I don't know how to edit a
post after I've posted it.
On Wednesday, November 14, 2018 at 10:31:34 PM UTC-8, Michael Beeson wrote:
>
> After quite some searching I did not succeed to find documentation for
> sage functions to work with complex numbers as much as I would like.
> For example if I have a complicated rational expression, how can I tell
> Sage "bring this to the form a + bi". It seems real() and imag() only
> work
> if no pre-processing is needed. How about "multiply numerator and
> denominator by denominator.conjugate()" ? There's probably a chapter in
> the documentation about this, could someone please point me to it, I
> seem to be incompetent at finding it, sorry.
>
> Since people want something concrete to look at, not just a general
> question, here is some code. You'll see that it computes a certain
> complex function (actually two of them)
> with integer parameters N and M, the solution(s) of a certain equation.
> I'd like to compute that the absolute value of those expressions must be 1.
> The
> code below computes it numerically for some more or less random values of
> N and M, and it is 1.0000 for those values, but I can't figure out how to
> compute it symbolically. Also, if there's a better way to do polynomial
> division than I've used below, please tell me.
>
> def nov13b():
> var('p,q,r,N,M,x')
> a = sqrt(3)/2
> b = (x-x^(-1))/(2*i)
> c = (sqrt(3)/2)* (x+x^(-1))/2 + (1/2)*(x-x^(-1))/(2*i)
> X = (M/3)*(a+b+c)
> f = 24*(X^2-N*b*c)*x^2
> g = (f.maxima_methods().divide(x+1)[0]).full_simplify()
> print(g.full_simplify())
> print("")
> t = exp(-pi*i/3)
> print(g(x=t).full_simplify())
> print("")
> h = (g.maxima_methods().divide(x-t)[0]).full_simplify()
> print("h = ")
> print(h)
> print("")
> answers = solve(h,x)
> assume(N,'integer')
> assume(M,'integer')
> for u in answers:
> print("")
> ans = u.rhs().simplify()
> for k in range(230,245):
> ans_numerical = abs(ans.substitute(M=11,N=243)).simplify()
> print(n(ans_numerical))
>
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.