I realized that you may be just looking for the Python complex type.  To
get that you can do:
sage: j = complex(i)
sage: (3 + 4*j)^2
(-7+24j)

Here are some other options.  The first involves using number field
arithmetic, so it may not be what you want (you can't use floating point
values in the results):
sage: Q.<j> = QuadraticField(-1) # for an exact version
sage: (3 + 4*j)^2
24*j - 7

If you just want j in the input and don't care about the output display,
that's easy:
sage: j = i # for the symbolic ring
sage: (3 + 4*j)^2
24*I - 7
sage: j = CDF.gen(0) # for double precision
sage: (3 + 4*j)^2
-6.999999999999997 + 24.0*I
sage: C.<j> = ComplexField(100) # higher precision
sage: (3 + 4*j)^2
-7.0000000000000000000000000000 + 24.000000000000000000000000000*I
David

On Fri, Apr 12, 2019 at 1:59 PM rjf <fate...@gmail.com> wrote:

> why not just use j, and tell sage that j^2=-1?
> Depends on how much of Sage you
> expect to understand this.
>
> (the use of j  is common in electrical engineering,
> for those who have not encountered this before...)
>

If you just want to be able to use j in your input (rather than having
complex numbers display with j):

sage: j = i # for the symbolic ring
sage: 3 + 4*j
4*I + 3
sage: Q.<j> = QuadraticField(-1) # for an exact version
sage: 3 + 4*j
4*j + 3

RJF
>
> On Friday, April 12, 2019 at 1:39:51 AM UTC-7, David Roe wrote:
>>
>> Is this what you're looking for?
>>
>> sage: z = ComplexNumber(1,2)
>> sage: z
>> 1.00000000000000 + 2.00000000000000*I
>> sage: print z.str(istr='j')
>> 1.0000000000000000 + 2.0000000000000000*j
>>
>> I don't think there's a global way to do this in Sage.  I'm also not
>> quite sure which kind of complex number you're working with; can you
>> provide Sage commands?
>> David
>>
>> On Fri, Apr 12, 2019 at 4:23 AM <nghi...@moet.edu.vn> wrote:
>>
>>> Hello everybody,
>>> Ín sage, how change complex number symbols:
>>> i^2=-1, z=a+bi
>>> Now I want
>>> j^2=-1, z=a+bj
>>> Thank you!
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "sage-devel" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to sage-...@googlegroups.com.
>>> To post to this group, send email to sage-...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/sage-devel.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to