(complex) root of unity - Printable Version +- HP Forums ( https://www.hpmuseum.org/forum)+-- Forum: HP Calculators (and very old HP Computers) ( /forum-3.html)+--- Forum: HP Prime ( /forum-5.html)+--- Thread: (complex) root of unity ( /thread-16187.html) |

(complex) root of unity - salvomic - 01-16-2021 02:47 PM
hi, first of try by myself to write a formule, I wonder if there is already for the Prime a program or app to get "all the complex root of unity (or any complex number) (see https://en.wikipedia.org/wiki/Root_of_unity), in other words, I need a program or routine to calculate all real and complex roots of any real or complex number, returned in a list or matrix... Thanks a lot, Salvo RE: (complex) root of unity - rprosperi - 01-16-2021 02:57 PM
(01-16-2021 02:47 PM)salvomic Wrote: ...I need a program or routine to calculate all real and complex roots of any real or complex number, returned in a list or matrix... Roots of a number? Perhaps if you provide an example it would be more clear? RE: (complex) root of unity - robmio - 01-16-2021 03:24 PM
Is the example I report correct? See the attachment. RE: (complex) root of unity - Albert Chan - 01-16-2021 03:40 PM
Assumed n is positive integer. Cas> rootsOfOne(n) := e^(2*pi*i*range(n)/n) Cas> rootsOfOne(3) [1, 1/2*√3*i-1/2, -1/2*√3*i-1/2] Cas> rootsOfz(z,n) := z^(1/n) * rootsOfOne(n) Cas> approx(rootsOfz(3+4i, 3)) [ 1.62893714592 +0.520174502305*i, −1.26495290636 +1.15061369838*i, −0.363984239564-1.67078820069*i] Cas> Ans .^ 3 [3.+4.*i, 3.+4.*i, 3.+4.*i] RE: (complex) root of unity - salvomic - 01-16-2021 03:53 PM
(01-16-2021 02:57 PM)rprosperi Wrote: Roots of a number? e.g. the three roots of 3√1 or the four of 4√-3 or the two of √(1+i) ... Like the function in Math1 pac for HP 41CX; input img and real part of the complex number, then the nRth exponent, to get the n roots... See here the three roots of unity, but I need something to get the roots of any complex number. Code:
The solution of robmio below could be ok, with some semplications, however... Salvo RE: (complex) root of unity - salvomic - 01-16-2021 03:56 PM
(01-16-2021 03:24 PM)robmio Wrote: Is the example I report correct? yes, at least this works, however better to simplify... RE: (complex) root of unity - salvomic - 01-16-2021 03:58 PM
(01-16-2021 03:40 PM)Albert Chan Wrote: Assumed n is positive integer. well, thanks, I'll try this. Salvo RE: (complex) root of unity - salvomic - 01-16-2021 05:27 PM
(01-16-2021 03:40 PM)Albert Chan Wrote: Assumed n is positive integer. something like this, then Code:
but: rootOFOne(3) I get "Error: Bad argument type" RE: (complex) root of unity - robmio - 01-16-2021 05:42 PM
it seems that within a program the HP PRIME does not recognize the "range" command RE: (complex) root of unity - robmio - 01-16-2021 05:47 PM
if you rewrite the program as CAS, it works. RE: (complex) root of unity - salvomic - 01-16-2021 06:02 PM
(01-16-2021 05:47 PM)robmio Wrote: if you rewrite the program as CAS, it works. yes, actually. Now: Code:
it works, but I get first a warning "Recursive" (see attached images). Then, trying with "3+4i" I get a little square in the matrix (second item): I don't know what's the reason... Salvo RE: (complex) root of unity - robmio - 01-16-2021 06:12 PM
The small square in the HP PRIME G2 with firmware 20200121 replaces the three dots that appear in the HP Prime Virtual Calculator lists or vectors Code:
RE: (complex) root of unity - salvomic - 01-16-2021 06:17 PM
(01-16-2021 06:12 PM)robmio Wrote: The small square in the HP PRIME G2 with firmware 20200121 replaces the three dots that appear in the HP Prime Virtual Calculator lists or vectors yes, ok, I had this problem in another program of mine and I solved there shorting the decimal places. Is there a way to avoid that? Using Approx the small square is still there, without showing the second value of the root... Salvo RE: (complex) root of unity - robmio - 01-16-2021 06:28 PM
see what happens if I use HP Prime Virtual Calculator on PC: instead of the square there are three dots. The square is a feature of HP PRIME G2 with filrmware 20200121 RE: (complex) root of unity - salvomic - 01-16-2021 06:37 PM
(01-16-2021 06:28 PM)robmio Wrote: see what happens if I use HP Prime Virtual Calculator on PC: instead of the square there are three dots. The square is a feature of HP PRIME G2 with filrmware 20200121 yes, I'm seeing. I wonder if it is possible to show also the second item, without the dots (or the square)... RE: (complex) root of unity - robmio - 01-16-2021 06:40 PM
To see the second value, the third, and so on, use the "Show" option RE: (complex) root of unity - salvomic - 01-16-2021 06:48 PM
(01-16-2021 06:40 PM)robmio Wrote: To see the second value, the third, and so on, use the "Show" option oh, well, I've forgot that thanks Salvo RE: (complex) root of unity - Jon Higgins - 12-26-2021 11:45 AM
Hello salvomic, Re, your post: "I need a program or routine to calculate all real and complex roots of any real or complex number, returned in a list or matrix..." You might be interested in this solution for your problem that I stumbled across: In CAS, For the fourth root of unity, use POLYROOT like this and enter unity as the complex number 1+0*i: POLYROOT(X^4-(1+0*i))sto L1 .......(1) Press “Enter”: The results are in L1: (-1, -i, i, 1); scroll up and down to see them on the "contents" line. In fact POLYROOT(X^n-1)sto L1 works for the case of n.th roots of unity. For n.th roots of any complex number stored in a List, use the format above in (1). Please see the attachment. Note that I did try and implement this in a program, but I couldn't get it to work. (I am new here and this is my first post!) |