Ask Your Question
1

Human readable representation of formulas

asked 2013-04-29 13:55:02 +0100

anonymous user

Anonymous

updated 2013-04-29 15:39:45 +0100

calc314 gravatar image

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 flag offensive close merge delete

Comments

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

rickhg12hs gravatar imagerickhg12hs ( 2013-04-29 18:24:26 +0100 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-04-29 15:39:23 +0100

calc314 gravatar image

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.

edit flag offensive delete link more
0

answered 2013-04-29 16:42:48 +0100

this post is marked as community wiki

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?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-04-29 13:55:02 +0100

Seen: 557 times

Last updated: Apr 29 '13