Ask Your Question
1

Using "j" for Imaginary Unit?

asked 2013-04-19 02:17:35 +0100

rickhg12hs gravatar image

updated 2015-01-14 14:52:15 +0100

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

edit retag flag offensive close merge delete

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 ( 2013-04-21 18:52:21 +0100 )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!

rickhg12hs gravatar imagerickhg12hs ( 2013-05-05 18:22:09 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2013-04-19 04:38:27 +0100

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 )

edit flag offensive delete link more

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 ( 2013-04-19 09:44:06 +0100 )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.

Luiz Roberto Meier gravatar imageLuiz Roberto Meier ( 2013-04-19 20:59:33 +0100 )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.

kcrisman gravatar imagekcrisman ( 2013-04-19 23:56:54 +0100 )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 :)

kcrisman gravatar imagekcrisman ( 2013-04-20 00:09:56 +0100 )edit

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: 2013-04-19 02:17:35 +0100

Seen: 2,242 times

Last updated: Apr 19 '13