# Using "j" for Imaginary Unit?

This is probably trivial, but it's a minor annoyance that I'd like to fix.

Is there a way to define "j" to be the imaginary unit so that it not only represents "i" (in all expressions,etc.) but also appears in output as "j"?

sage: var('j,w,t')
(j, w, t)
sage: j=i
sage: j
I
sage: exp(j*w*t)
e^(I*t*w)
sage:


I'd like "j" to have the value of "i" but still appear as "j" in all output (LaTeX too!).

edit retag close merge delete

Poked around a bit more and found that this was no help. 8-( sage:SR(QuadraticField(-1,name='j',latex_name='j').gen()) I

( 2013-04-21 18:52:21 +0200 )edit

Even if you del(I) and j = SR(QuadraticField(-1,name='j',latex_name='j').gen()), j^3 is still -I! "I" is like Wolverine, you can't kill it!

( 2013-05-05 18:22:09 +0200 )edit

Sort by » oldest newest most voted

After peruse a lot of files and docs maybe I have found a simple solution:

sage: var('j,w,t')

(j, w, t)

sage: j = complex(I)

sage: exp( j * w * t )

e^( 1j * w * t )

more

2

Be careful with this. Not only will this code overwrite that j is a symbolic variable, it now means that j is a *Python* complex number, which will not have access to a lot of Sage-custom stuff. This might still work for the poster, but mixing types like that can have unforeseen consequences.

( 2013-04-19 09:44:06 +0200 )edit

Mr... kcrisman, You keep warning my helps. I'm just trying to help. If later the solution isn't sufficient or the correct one, it isn't my fault but the lack or organizational documentation. There is a pain to find some simple solutions when it isn't in the name of a section of some kind of manual. As you know much more than me, why don't you help to solve? Give a best answer to the above question, you will help the user and forget my ignorance.

( 2013-04-19 20:59:33 +0200 )edit

I'm sorry if you feel that I'm warning several of your answers. Your answer might indeed be a good one for the user! I'm just pointing out some things which one might want to keep in mind - I don't know what the poster wants. If I felt the answer was bad, I would downvote it, and that is definitely not appropriate here.

( 2013-04-19 23:56:54 +0200 )edit

And if I had an answer on the tip of my tongue, of course I'd submit it :) but thus far yours is the closest :)

( 2013-04-20 00:09:56 +0200 )edit