Ask Your Question
1

Using "j" for Imaginary Unit?

asked 12 years ago

rickhg12hs gravatar image

updated 10 years ago

FrédéricC gravatar image

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!).

Preview: (hide)

Comments

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

rickhg12hs gravatar imagerickhg12hs ( 11 years ago )

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!

rickhg12hs gravatar imagerickhg12hs ( 11 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 12 years ago

Luiz Roberto Meier gravatar image

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 )

Preview: (hide)
link

Comments

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.

kcrisman gravatar imagekcrisman ( 12 years ago )

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.

Luiz Roberto Meier gravatar imageLuiz Roberto Meier ( 12 years ago )

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.

kcrisman gravatar imagekcrisman ( 12 years ago )

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 :)

kcrisman gravatar imagekcrisman ( 12 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 12 years ago

Seen: 2,296 times

Last updated: Apr 19 '13