Human readable representation of formulas Anonymous

Hello,

i do have question regarding the representation of formulas in sage.

Is a formula typed into sage, the routines will transform the expression, which could be less human readable. How can I programm sage to use the typed in formula and still compute a solution?

Example:

f(h)=0.19+0.91*((h+140)/760)^2

will be transformed to

(1.57548476454294e-6)*(h + 140)^2 + 0.190000000000000

Sincerely

edit retag close merge delete

Are you trying to preserve the exact input? Perhaps a string literal is what you need.

Sort by » oldest newest most voted

In this example you've given, I'd suggest writing 0.19 and 0.91 as 19/100 and 91/100, respectively. Then, Sage will not attempt to use floating point arithmetic on them, and the expressions will appear nicer. For a more attractive output, you can also use show(f(h)) to have a nicely typeset version appear in the notebook.

more

answered 2013-04-29 09:42:48 -0500 This post is a wiki. Anyone with karma >750 is welcome to improve it.

Thank you for your response to my question. Output with your notation:

f(h)=19/100+(91/100)*((h+140)/760)^2
--> 91/57760000*(h + 140)^2 + 19/100

Other example:

S(A) = (0.25+1.91*((A+140)/760)^2) >= 0.85
--> (3.30678670360111e-6)*(A + 140)^2 + 0.250000000000000 >= (17/20)

S(A) = (25/100+191/100*((A+140)/760)^2) >= 85/100
-->  191/57760000*(A + 140)^2 + 1/4 >= (17/20)

Is there a other way to display the same formula as programmed, because for a quick review the output is not handy?

more