[Tutor] Typing Equations-A Newbie
Daniel Yoo
dyoo@hkn.eecs.berkeley.edu
Thu, 15 Mar 2001 03:47:58 -0800 (PST)
On Wed, 14 Mar 2001 DavidCraig@PIA.CA.GOV wrote:
> How do I type formulas using superscripts/subscripts into Idle?
>
> I have tried importing them from MS Word to no avail. Current Platform is
> WIN 98.
Unfortunately, most programming languages don't directly support the use
of subscripts and superscripts --- you'll need to translate them to a
linear form. For example:
2 2
a + b
will need to be written as:
a**2 + b**2
in Python. Likewise, all the subscripted variables will need to be
renamed. It depends on one relationship the subscripts are trying to
say: if the subscripts mean some sort of sequence, like:
10
Sum a
n=0 n
,the sum of a_0, a_2, ..., a_10, then it might be a good idea to give
Python the information that our a's are all part of a sequence, by making
it a list. Gosh, I feel handwavy today.
If you show us what equation you're trying to encode, we can help find a
way to translate it into Python. Good luck!