ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 03 Oct 2019 15:11:11 +0200expand large expressions made of complex functions and variableshttps://ask.sagemath.org/question/48165/expand-large-expressions-made-of-complex-functions-and-variables/I'm trying to use Sagemath notebook environment without much prior knowledge of Sage.
What I tried to do was define some variables (R, a, x, y, x, t...) and then some functions expressed in these variables.
The expressions get quite large and complex this way as they are functions built of other functions.
Last line of my code I'm trying to expand a large complex-valued symbolic expression using the variables of the functions (so not their values). I use expand() and collectterms(x,y,z,t) to get a result that is sorted by powers of x,y,z,t.
When I used this with less complicated expressions it seemed to work OK giving me some reassurance that my syntax should be correct.
But when the expressions get larger (see my code below) the outcome isn't correct anymore. I get a result without error messages, but the result is not correct.
For example : the code below gives me a result without any imaginary numbers, also the real part is wrong.
Does anyone know what is going on here? Is my syntax wrong? Or does Sage fail without error when expressions get large? And if so: are there ways to do this correctly? Thanks in advance!
clos(R,a)=((1/(2*R))+R/2)*cos(a)+I*((1/(2*R))-R/2)*sin(a)
slin(R,a)=((1/(2*R))+R/2)*sin(a)-I*((1/(2*R))-R/2)*cos(a)
a_1(R,a)=(1/5)*sqrt(5)
a_2(R,a)=-(1/20)*sqrt(5)-(1/4)+(1/2)*clos(R,a)
a_3(R,a)=-(1/20)*sqrt(5)+(1/4)+(1/2)*slin(R,a)
a_4(R,a)=-(1/20)*sqrt(5)-(1/4)-(1/2)*clos(R,a)
a_5(R,a)=-(1/20)*sqrt(5)+(1/4)-(1/2)*slin(R,a)
b_1(R,a)=(1/5)*sqrt(5)
b_2(R,a)=-(1/20)*sqrt(5)+(1/4)-(1/2)*slin(R,a)
b_3(R,a)=-(1/20)*sqrt(5)-(1/4)+(1/2)*clos(R,a)
b_4(R,a)=-(1/20)*sqrt(5)+(1/4)+(1/2)*slin(R,a)
b_5(R,a)=-(1/20)*sqrt(5)-(1/4)-(1/2)*clos(R,a)
cc_1(R,a)=(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