On Thu, Dec 4, 2008 at 1:39 PM, Tim Lahey <[EMAIL PROTECTED]> wrote:
>
> On Dec 4, 2008, at 4:33 PM, William Stein wrote:
>
>>
>> On Tue, Dec 2, 2008 at 8:21 PM, Jason Grout <[EMAIL PROTECTED]>
>> wrote:
>>>
>>> Tim Lahey wrote:
>>>>
>>>> Hi,
>>>>
>>>> Thanks. I was kind of hoping for something less drastic,
>>>> but that works. In Maple there is just a variable you can
>>>> set which controls things, so you can do it on a per script
>>>> basis.
>>>>
>>>
>>>
>>> This is something that has come up before too.  I think it might make
>>> sense to make a module-level variable in the calculus file,
>>> sage.calculus.imaginary_i or something.  Set it by default to "I", but
>>> let people change it.  Then the repr function for I could just return
>>> that variable.  Then things won't be quite so invasive to change the
>>> printed representation.
>>
>> It's also invasive, since either way, all code in all of sage that
>> prints "I" will print using what you change it to.  However, an
>> additional benefit to having a function like sage.calculus.imaginary_i
>> is that it will work even if (in fact, when) the "I" constant gets
>> rewritten in Cython, which would make changing the _repr_ function
>> impossible.
>
> However, during a worksheet/script, I'd want all Sage code to use the
> symbol I specified for sqrt(-1), both for display purposes and for
> specifying expressions.
>
> The reason I bring this up is that I is the symbol for moment of inertia
> in solid mechanics and i is the symbol for current in electrical
> engineering. Since I'm interested in both, I'd like to be able to use
> them in their normal engineering fashion. There's a reason why
> engineers use j for the imaginary unit. I happen to use _j in Maple so
> I can use j as a loop variable.
>
> Cheers,
>
> Tim.

In case my response above was ambiguous, I'm very much in favor of their
being a way to change how the symbolic I prints.  Wait a minute, I just realized
that I designed and imlemented a very nice way to do this sort of thing over
THREE YEARS ago, but nobody ever seemed to use it.  Check this, which has
worked (more generically) since Sage-1.0:

sage: I.rename('_j')
sage: I
_j
sage: expand((1+i)^2)
2*_j
sage: expand((2+3*i)^2)
12*_j - 5

You can actually rename most anything that isn't defined by Cython code:

sage: f = sin(2*I) + cos(3*x); f
cos(3*x) + _j*sinh(2)
sage: f.rename('fred')
sage: f
fred

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to