ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 05 May 2013 11:22:09 -0500Using "j" for Imaginary Unit?https://ask.sagemath.org/question/10039/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!).
Thu, 18 Apr 2013 19:17:35 -0500https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/Comment by rickhg12hs for <p>This is probably trivial, but it's a minor annoyance that I'd like to fix.</p>
<p>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"?</p>
<pre><code>sage: var('j,w,t')
(j, w, t)
sage: j=i
sage: j
I
sage: exp(j*w*t)
e^(I*t*w)
sage:
</code></pre>
<p>I'd like "j" to have the value of "i" but still appear as "j" in all output (LaTeX too!).</p>
https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17767#post-id-17767Even 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!Sun, 05 May 2013 11:22:09 -0500https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17767#post-id-17767Comment by rickhg12hs for <p>This is probably trivial, but it's a minor annoyance that I'd like to fix.</p>
<p>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"?</p>
<pre><code>sage: var('j,w,t')
(j, w, t)
sage: j=i
sage: j
I
sage: exp(j*w*t)
e^(I*t*w)
sage:
</code></pre>
<p>I'd like "j" to have the value of "i" but still appear as "j" in all output (LaTeX too!).</p>
https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17833#post-id-17833Poked around a bit more and found that this was no help. 8-( sage:SR(QuadraticField(-1,name='j',latex_name='j').gen())
I
Sun, 21 Apr 2013 11:52:21 -0500https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17833#post-id-17833Answer by Luiz Roberto Meier for <p>This is probably trivial, but it's a minor annoyance that I'd like to fix.</p>
<p>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"?</p>
<pre><code>sage: var('j,w,t')
(j, w, t)
sage: j=i
sage: j
I
sage: exp(j*w*t)
e^(I*t*w)
sage:
</code></pre>
<p>I'd like "j" to have the value of "i" but still appear as "j" in all output (LaTeX too!).</p>
https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?answer=14803#post-id-14803After 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 )Thu, 18 Apr 2013 21:38:27 -0500https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?answer=14803#post-id-14803Comment by kcrisman for <p>After peruse a lot of files and docs maybe I have found a simple solution:</p>
<p>sage: var('j,w,t')</p>
<p>(j, w, t)</p>
<p>sage: j = complex(I)</p>
<p>sage: exp( j * w * t )</p>
<p>e^( 1j * w * t )</p>
https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17852#post-id-17852Be 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.Fri, 19 Apr 2013 02:44:06 -0500https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17852#post-id-17852Comment by Luiz Roberto Meier for <p>After peruse a lot of files and docs maybe I have found a simple solution:</p>
<p>sage: var('j,w,t')</p>
<p>(j, w, t)</p>
<p>sage: j = complex(I)</p>
<p>sage: exp( j * w * t )</p>
<p>e^( 1j * w * t )</p>
https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17847#post-id-17847Mr... 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.Fri, 19 Apr 2013 13:59:33 -0500https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17847#post-id-17847Comment by kcrisman for <p>After peruse a lot of files and docs maybe I have found a simple solution:</p>
<p>sage: var('j,w,t')</p>
<p>(j, w, t)</p>
<p>sage: j = complex(I)</p>
<p>sage: exp( j * w * t )</p>
<p>e^( 1j * w * t )</p>
https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17845#post-id-17845I'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.Fri, 19 Apr 2013 16:56:54 -0500https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17845#post-id-17845Comment by kcrisman for <p>After peruse a lot of files and docs maybe I have found a simple solution:</p>
<p>sage: var('j,w,t')</p>
<p>(j, w, t)</p>
<p>sage: j = complex(I)</p>
<p>sage: exp( j * w * t )</p>
<p>e^( 1j * w * t )</p>
https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17844#post-id-17844And if I had an answer on the tip of my tongue, of course I'd submit it :) but thus far yours is the closest :)Fri, 19 Apr 2013 17:09:56 -0500https://ask.sagemath.org/question/10039/using-j-for-imaginary-unit/?comment=17844#post-id-17844