Ask Your Question

Revision history [back]

If you can see a reasonable way to split the equation up, you could have sage store the pieces in separate variables and print them separately . . . but the obvious example I tried

sum(i*x**i for i in range(30))

automatically prints on several different lines anyway. Could you update your original question with an example of the kind of equation you're having trouble with?

If you can see a reasonable way to split the equation up, you could have sage store the pieces in separate variables and print them separately . . . but the obvious example I tried

sum(i*x**i for i in range(30))

automatically prints on several different lines anyway. Could you update

For your original question case, if you change the definition of f to

f= A2*Term1 + B2*Term2 == (42/10)**2

and change the last part to

newf=f(k=kvalue) 
newg=g(k=kvalue) 
opf = newf.lhs().operands()
show(opf[0])
print("+")
show(opf[1]==newf.rhs())
show(newg)

you'll get something like

image description

This could maybe be improved a little, but illustrates two key things:

  • use .operands() to split an equation or symbolic expression into pieces which you can print separately

  • the additional zeroes are coming from the precision of the real numbers you're working with an example of the kind of equation you're having trouble with?

    (53 bits by default, I think). If you use rationals instead, you'll get exact values, or you could use lower-precision real numbers.