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.Mon, 29 Apr 2013 18:24:26 +0200Human readable representation of formulashttps://ask.sagemath.org/question/10079/human-readable-representation-of-formulas/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
SincerelyMon, 29 Apr 2013 13:55:02 +0200https://ask.sagemath.org/question/10079/human-readable-representation-of-formulas/Comment by rickhg12hs for <p>Hello,</p>
<p>i do have question regarding the representation of formulas in sage.</p>
<p>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?</p>
<p>Example:</p>
<pre><code>f(h)=0.19+0.91*((h+140)/760)^2
</code></pre>
<p>will be transformed to</p>
<pre><code>(1.57548476454294e-6)*(h + 140)^2 + 0.190000000000000
</code></pre>
<p>Sincerely</p>
https://ask.sagemath.org/question/10079/human-readable-representation-of-formulas/?comment=17788#post-id-17788Are you trying to preserve the exact input? Perhaps a string literal is what you need.Mon, 29 Apr 2013 18:24:26 +0200https://ask.sagemath.org/question/10079/human-readable-representation-of-formulas/?comment=17788#post-id-17788Answer by reb_reb for <p>Hello,</p>
<p>i do have question regarding the representation of formulas in sage.</p>
<p>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?</p>
<p>Example:</p>
<pre><code>f(h)=0.19+0.91*((h+140)/760)^2
</code></pre>
<p>will be transformed to</p>
<pre><code>(1.57548476454294e-6)*(h + 140)^2 + 0.190000000000000
</code></pre>
<p>Sincerely</p>
https://ask.sagemath.org/question/10079/human-readable-representation-of-formulas/?answer=14866#post-id-14866Thank 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?
Mon, 29 Apr 2013 16:42:48 +0200https://ask.sagemath.org/question/10079/human-readable-representation-of-formulas/?answer=14866#post-id-14866Answer by calc314 for <p>Hello,</p>
<p>i do have question regarding the representation of formulas in sage.</p>
<p>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?</p>
<p>Example:</p>
<pre><code>f(h)=0.19+0.91*((h+140)/760)^2
</code></pre>
<p>will be transformed to</p>
<pre><code>(1.57548476454294e-6)*(h + 140)^2 + 0.190000000000000
</code></pre>
<p>Sincerely</p>
https://ask.sagemath.org/question/10079/human-readable-representation-of-formulas/?answer=14865#post-id-14865In 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.
Mon, 29 Apr 2013 15:39:23 +0200https://ask.sagemath.org/question/10079/human-readable-representation-of-formulas/?answer=14865#post-id-14865