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.Sat, 13 Nov 2021 10:43:28 +0100Has anyone found a way to handle units in sagemath ?https://ask.sagemath.org/question/59657/has-anyone-found-a-way-to-handle-units-in-sagemath/Hi,
I am looking for a way to handle units in Sagemath, both numerically and symbolically. I am trying to see how I can emulate the Mathcad capability of unit consistency in Sagemath.
For example,
How would I be able to do the following:
Symbolic: delta= PL/AE , P=3F N, F=delta*A*E/3*L N
numerical: 1kN +500N = 1.5kN
Thanks for the helpTue, 09 Nov 2021 12:35:37 +0100https://ask.sagemath.org/question/59657/has-anyone-found-a-way-to-handle-units-in-sagemath/Answer by Emmanuel Charpentier for <p>Hi,
I am looking for a way to handle units in Sagemath, both numerically and symbolically. I am trying to see how I can emulate the Mathcad capability of unit consistency in Sagemath.
For example,
How would I be able to do the following:
Symbolic: delta= PL/AE , P=3F N, F=delta<em>A</em>E/3*L N</p>
<p>numerical: 1kN +500N = 1.5kN</p>
<p>Thanks for the help</p>
https://ask.sagemath.org/question/59657/has-anyone-found-a-way-to-handle-units-in-sagemath/?answer=59666#post-id-59666[This](https://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/units.html) may enlighten you
I found this facility a bit awkward (at least initially) but useful. LaTeX output may use a bit of love...Tue, 09 Nov 2021 21:35:11 +0100https://ask.sagemath.org/question/59657/has-anyone-found-a-way-to-handle-units-in-sagemath/?answer=59666#post-id-59666Comment by aurelius_nero for <p><a href="https://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/units.html">This</a> may enlighten you</p>
<p>I found this facility a bit awkward (at least initially) but useful. LaTeX output may use a bit of love...</p>
https://ask.sagemath.org/question/59657/has-anyone-found-a-way-to-handle-units-in-sagemath/?comment=59728#post-id-59728@Emmanuel Charpentier Does this work the same way if I want to change the unit of the same variable ?
for example;
L =10m to L=10000mm ?Sat, 13 Nov 2021 10:43:28 +0100https://ask.sagemath.org/question/59657/has-anyone-found-a-way-to-handle-units-in-sagemath/?comment=59728#post-id-59728Comment by Emmanuel Charpentier for <p><a href="https://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/units.html">This</a> may enlighten you</p>
<p>I found this facility a bit awkward (at least initially) but useful. LaTeX output may use a bit of love...</p>
https://ask.sagemath.org/question/59657/has-anyone-found-a-way-to-handle-units-in-sagemath/?comment=59671#post-id-59671> You can't change m to mm and vice versa easily.
Huh ?
m=units.length.meter
mm=units.length.millimeter
sage.symbolic.units.convert(2/10*m, mm)
200*millimeter
Also :
(200*mm).subs(mm==1/1000*m)
1/5*meterWed, 10 Nov 2021 10:11:42 +0100https://ask.sagemath.org/question/59657/has-anyone-found-a-way-to-handle-units-in-sagemath/?comment=59671#post-id-59671Comment by aurelius_nero for <p><a href="https://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/units.html">This</a> may enlighten you</p>
<p>I found this facility a bit awkward (at least initially) but useful. LaTeX output may use a bit of love...</p>
https://ask.sagemath.org/question/59657/has-anyone-found-a-way-to-handle-units-in-sagemath/?comment=59670#post-id-59670@Emmanuel Charpentier I have seen that documentation. Though, it functions like a symbolic variable. You can't change m to mm and vice versa easily.Wed, 10 Nov 2021 01:42:40 +0100https://ask.sagemath.org/question/59657/has-anyone-found-a-way-to-handle-units-in-sagemath/?comment=59670#post-id-59670