I know this is really basic, but for some reason I cannot figure this out and my searching (here, sage website, google, etc) has not yielded me any results! I just started using sage, literally, yesterday.
I am using solve() to solve an equation for q1 in terms of q2. The solution of this is saved, but when I print it, it prints as an exact answer, but I want it in decimal/approximate form. I have tried using the n() function, but I get an error when trying it. Here is an example: -------------------------------------------------- q1, q2 = var('q1, q2') r = 0.60 t1 = 0.005 t2 = 0.007 d = 2.0 A1 = (1/2)*pi*r*r A2 = (1/2)*d*(2*r) theta1 = 1/(2*A1)*(q1*2*pi*r/t1+(q1-q2)*2*r/t1) theta2 = 1/(2*A2)*(q2*d/t2+q2*sqrt(d^2+(2*r)^2)/t2+(q2-q1)*2*r/t1) sol_q1 = solve([theta1==theta2], q1) print sol_q1 print sol_q1[0].substitute(q2=1).right().n() -------------------------------------------------- When this is run, the result for sol_q1 is: q1 = (223317 pi + 416000)/ ((223317 pi + 416000) q2)*q2 The last line does work to give me the desired value (0.58239....), but this is definitely not an ideal way of getting it! And of course this wouldn't work for a more complicated result (since I use q2=1). I've tried many other combinations of sol_q1.n(), sol_q1[0].n(), etc, etc, etc...but they all give me errors. As a note: sol_q1 is a Sequence (list of the answers) sol_q1[0] is a SymbolicEquation Thanks for the help, Scott PS: I tried using the for loop a little more than half way down on this page: <http://www.sagemath.org/doc/reference/sage/symbolic/relation.html> but my solution are functions of q2, not numbers, so it fails. --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---