2 Sep 06:54
{science, python} newb seeks {calculation, formatting} advice
From: Tom Roche <Tom_Roche@...>
Subject: {science, python} newb seeks {calculation, formatting} advice
Newsgroups: gmane.org.user-groups.zope.trizpug
Date: 2008-09-02 04:57:25 GMT
Subject: {science, python} newb seeks {calculation, formatting} advice
Newsgroups: gmane.org.user-groups.zope.trizpug
Date: 2008-09-02 04:57:25 GMT
Basically I'm looking for help with my homeworkwhich involves outputting formatted scientific equations and their solutions. I'm wondering how to more productively use python to create documents with equations (including units), and their solutions. What I mean: I'm starting grad school, and they're expecting me to hand in stuff (basically chemistry and physics problems) in PDF. I didn't hafta do that as an undergrad (which wasn't *that* long ago), so I'm whacking together a solution. Being too busy/lazy for TeX at the moment, I'm using OpenOffice: + it ain't M$ Office + OO Writer generates PDFs easily/cleanly OOTB + OO Math's equation editor is easy, and it integrates pretty well with Writer - no integrated solver that I can see. (If you know how to make OO do this, please lemme know. I'm lazy enough that I want the word processor to solve my equations for me, and, though I did search a bit, possibly too lazy to find out how to make that happen.) So my workflow now is like 0 setup an equation in OO (including any required unit conversions <yuck/>) 1 bail to python for the calculations. That I can basically cut/paste out of OO Math into the shell dulls the pain somewhat: >>> import math >>> d=1e-6 >>> V=math.pi*(d**3)/6 >>> rho_p=1000 >>> m=rho_p*V >>> m_t=1e-11 # converting units in my head--"danger, Will Robinson!" >>> n_p=m_t/m >>> print '%3.2e' % (n_p) 1.91e+04 2 paste answers back into OO Math until I have all the equations done, and I can generate my PDF. I'd appreciate suggestions regarding easier/better ways to do this, especially (in increasing order of appreciation) * format coercion: e.g. is there a way that I can set something (like 'scale' in `bc`) once so that I could thereafter just do >>> m_t/m 1.91e+04 and get the results in the format I want without repeated print's? Extra credit for making it do the calculations with specified significant digits. * automating unit conversions * doing more serious math (coming down the pipeline before too long): matrices, numeric differentiation and integration. * automating solutions TIA, Tom Roche <Tom_Roche@...>
which involves
outputting formatted scientific equations and their solutions. I'm
wondering how to more productively use python to create documents with
equations (including units), and their solutions. What I mean:
I'm starting grad school, and they're expecting me to hand in stuff
(basically chemistry and physics problems) in PDF. I didn't hafta do
that as an undergrad (which wasn't *that* long ago), so I'm whacking
together a solution. Being too busy/lazy for TeX at the moment, I'm
using OpenOffice:
+ it ain't M$ Office
+ OO Writer generates PDFs easily/cleanly OOTB
+ OO Math's equation editor is easy, and it integrates pretty well
with Writer
- no integrated solver that I can see. (If you know how to make OO do
this, please lemme know. I'm lazy enough that I want the word
processor to solve my equations for me, and, though I did search a
bit, possibly too lazy to find out how to make that happen.)
So my workflow now is like
0 setup an equation in OO (including any required unit conversions
<yuck/>)
1 bail to python for the calculations. That I can basically cut/paste
out of OO Math into the shell dulls the pain somewhat:
>>> import math
>>> d=1e-6
>>> V=math.pi*(d**3)/6
>>> rho_p=1000
>>> m=rho_p*V
>>> m_t=1e-11 # converting units in my head--"danger, Will Robinson!"
>>> n_p=m_t/m
>>> print '%3.2e' % (n_p)
1.91e+04
2 paste answers back into OO Math
until I have all the equations done, and I can generate my PDF. I'd
appreciate suggestions regarding easier/better ways to do this,
especially (in increasing order of appreciation)
* format coercion: e.g. is there a way that I can set something (like
'scale' in `bc`) once so that I could thereafter just do
>>> m_t/m
1.91e+04
and get the results in the format I want without repeated print's?
Extra credit for making it do the calculations with specified
significant digits.
* automating unit conversions
* doing more serious math (coming down the pipeline before too long):
matrices, numeric differentiation and integration.
* automating solutions
TIA, Tom Roche <
RSS Feed