(Feature Request) - Convert to polar (phasor) notation in CAS
03-29-2020, 07:48 AM (This post was last modified: 03-30-2020 10:51 PM by Dands.)
Post: #1
 Dands Member Posts: 57 Joined: Jul 2015
(Feature Request) - Convert to polar (phasor) notation in CAS
Hi,

If you have a complex number in rectangular form in the home screen and want to convert it to phasor notation (r∠θ), you can simply press shift + "∠".

Why this doesn't work in CAS? Is there any way I can request this to HP?

-Edit-
See below an example of a matrix containing complex numbers in rectangular form and the result in phasor notation. This is easy to do in Home, but won't work in CAS.

Thanks
03-29-2020, 03:12 PM
Post: #2
 Eddie W. Shore Senior Member Posts: 1,448 Joined: Dec 2013
RE: Convert to polar (phasor) representation in CAS

In the mean time, there are two conversion CAS commands that work both in Home and CAS modes:

polar_coordinates( real + imag*i ) -> [ approximate radius, approximate angle ]

polar_coordinates( real, imag ) -> [ radius, angle ]
Approximate at Home, Exact at CAS

rectangular_coordinates( radius, angle ) -> [ real, imag ]
Approximate at Home, Exact at CAS

Both polar_coordinates and rectangular_coordiantes are found in the Catalog.

polar_coordinates is also found in [Toolbox], (App), Geometry, Cartesian, Polar Coordinates
03-30-2020, 09:06 PM
Post: #3
 Dands Member Posts: 57 Joined: Jul 2015
RE: Convert to polar (phasor) representation in CAS
(03-29-2020 03:12 PM)Eddie W. Shore Wrote:  You can file a bug report, see the thread about the Beta thread.

In the mean time, there are two conversion CAS commands that work both in Home and CAS modes:

polar_coordinates( real + imag*i ) -> [ approximate radius, approximate angle ]

polar_coordinates( real, imag ) -> [ radius, angle ]
Approximate at Home, Exact at CAS

rectangular_coordinates( radius, angle ) -> [ real, imag ]
Approximate at Home, Exact at CAS

Both polar_coordinates and rectangular_coordiantes are found in the Catalog.

polar_coordinates is also found in [Toolbox], (App), Geometry, Cartesian, Polar Coordinates

Thanks for your reply. Unfortunately those don't work well for me because I often pass matrices with multiple entries to be converted. I really wished the "home" functionality also worked in CAS because it's so easy to use. See below.

Also, where exactly should I request new features? How does posting them here gets sent to HP?

Thanks
03-30-2020, 09:56 PM
Post: #4
 rprosperi Super Moderator Posts: 5,681 Joined: Dec 2013
RE: Convert to polar (phasor) notation in CAS
(03-30-2020 09:06 PM)Dands Wrote:  Also, where exactly should I request new features? How does posting them here gets sent to HP?

Members of the Prime team are quite active MoHPC Forum members and they will see your posts here. That said, if you want to suggest new or modified features, it's best to make a new post with something like "Feature Request" in the title, rather than burying it on some other long or only somewhat related thread.

Also, history has shown that general enhancements that affect lots of users, with detailed explanations and examples of how the new (or modified) feature should (could) work receive the best response.

But also understand that deep inside the Prime, HOME and CAS modes are not tightly integrated, so quite often requests along the lines of "Please make CAS treatment of XYZ act like HOME mode" or vice-versa, can't practically be implemented. There are some areas where they obviously can behave similarly, but others where it either makes no sense, or isn't technically feasible.

--Bob Prosperi
03-30-2020, 10:49 PM
Post: #5
 Dands Member Posts: 57 Joined: Jul 2015
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
(03-30-2020 09:56 PM)rprosperi Wrote:
(03-30-2020 09:06 PM)Dands Wrote:  Also, where exactly should I request new features? How does posting them here gets sent to HP?

Members of the Prime team are quite active MoHPC Forum members and they will see your posts here. That said, if you want to suggest new or modified features, it's best to make a new post with something like "Feature Request" in the title, rather than burying it on some other long or only somewhat related thread.

Also, history has shown that general enhancements that affect lots of users, with detailed explanations and examples of how the new (or modified) feature should (could) work receive the best response.

But also understand that deep inside the Prime, HOME and CAS modes are not tightly integrated, so quite often requests along the lines of "Please make CAS treatment of XYZ act like HOME mode" or vice-versa, can't practically be implemented. There are some areas where they obviously can behave similarly, but others where it either makes no sense, or isn't technically feasible.

That's good to know. I will leave this post here as a request. Hopefully this functionality won't be too hard to implement.

Thanks
03-31-2020, 05:54 AM
Post: #6
 Tim Wessman Senior Member Posts: 2,290 Joined: Dec 2013
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
It actually is very hard to implement because there is no such thing as a "complex" object in the CAS. You have expressions that contain complex parts, but those can be in very varying forms and varieties. Whereas in home and numeric parts, the two values are intrinsically linked as a single object. That object has a flag that means "display in rectangular" or "display in polar". Hence nothing changes and it just toggles the bit on that individual object.

Bernard the CAS author could possibly extend the polar_coordinates/rectangular_coordinates to also work with vectors of vectors (there is no MATRIX object in CAS actually either, which is another major difference), but that will depend on him desiring to do so.

It will not be able to use the same display routines and keep the pairs together because that type of object just does not exist in CAS land...

TW

Although I work for HP, the views and opinions I post here are my own.
03-31-2020, 06:24 AM
Post: #7
 Dands Member Posts: 57 Joined: Jul 2015
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
(03-31-2020 05:54 AM)Tim Wessman Wrote:  It actually is very hard to implement because there is no such thing as a "complex" object in the CAS. You have expressions that contain complex parts, but those can be in very varying forms and varieties. Whereas in home and numeric parts, the two values are intrinsically linked as a single object. That object has a flag that means "display in rectangular" or "display in polar". Hence nothing changes and it just toggles the bit on that individual object.

Bernard the CAS author could possibly extend the polar_coordinates/rectangular_coordinates to also work with vectors of vectors (there is no MATRIX object in CAS actually either, which is another major difference), but that will depend on him desiring to do so.

It will not be able to use the same display routines and keep the pairs together because that type of object just does not exist in CAS land...

That is pretty interesting, kind of bad news...

I really wished CAS handled phasor notation better since it is so relevant in many electrical engineering applications.

Meanwhile, I just found a possible bug. In CAS, I can write 1∠45 and execute. The calculator will change the notation to ∠(1,45). But if you try yourself to use this notation, it gives you an error. See below. Might worth taking a look?

03-31-2020, 11:25 AM
Post: #8
 parisse Senior Member Posts: 1,255 Joined: Dec 2013
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
I have added some list processing to polar/rectangular_coordinates.
For the copy/paste problem with the angle symbol, it seems to happen only in textbook display mode, therefore it's probably not a CAS bug.
03-31-2020, 12:31 PM
Post: #9
 victorvbc Member Posts: 71 Joined: Jun 2019
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
This is the code I made for displaying polar coordinates {magnitude,angle}, it works with matrices and lists.

I'm also quite new to the Prime, so I don't know if there's any better way to do it...

Code:
 //This program takes an expression or matrix and turns it into polar coordinates #cas toPolar(z):=  BEGIN LOCAL sizes,j,k; IF type(z)=DOM_LIST THEN //check if is list/matrix   sizes:=SIZE(z); //get dimension of rows and columns   IF size(sizes)=1 THEN //row vector     FOR j FROM 1 to sizes DO       z[j]:=convert_polar(z[j]); //convert each element to polar     END;   ELSE //column vector or matrix     FOR j FROM 1 to sizes(1) DO       FOR k FROM 1 to sizes(2) DO         z[j,k]:=convert_polar(z[j,k]); //convert each element to polar       END;      END;   END; ELSE   z:=convert_polar(z); //single element END; RETURN z; END; convert_polar(x):= BEGIN   RETURN simplify({ABS(x),ARG(x)}); //conversion formula END; #end

Keep in mind that it's purely for display purposes, you can't make any operations with this format.

Also, if you want to convert any expressions that have real-valued variables, you should do something like assume(x,float) before doing the conversion. Otherwise you can have very complicated expressions.
03-31-2020, 04:22 PM
Post: #10
 Dands Member Posts: 57 Joined: Jul 2015
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
(03-31-2020 12:31 PM)victorvbc Wrote:  This is the code I made for displaying polar coordinates {magnitude,angle}, it works with matrices and lists.

I'm also quite new to the Prime, so I don't know if there's any better way to do it...

Code:
 //This program takes an expression or matrix and turns it into polar coordinates #cas toPolar(z):=  BEGIN LOCAL sizes,j,k; IF type(z)=DOM_LIST THEN //check if is list/matrix   sizes:=SIZE(z); //get dimension of rows and columns   IF size(sizes)=1 THEN //row vector     FOR j FROM 1 to sizes DO       z[j]:=convert_polar(z[j]); //convert each element to polar     END;   ELSE //column vector or matrix     FOR j FROM 1 to sizes(1) DO       FOR k FROM 1 to sizes(2) DO         z[j,k]:=convert_polar(z[j,k]); //convert each element to polar       END;      END;   END; ELSE   z:=convert_polar(z); //single element END; RETURN z; END; convert_polar(x):= BEGIN   RETURN simplify({ABS(x),ARG(x)}); //conversion formula END; #end

Keep in mind that it's purely for display purposes, you can't make any operations with this format.

Also, if you want to convert any expressions that have real-valued variables, you should do something like assume(x,float) before doing the conversion. Otherwise you can have very complicated expressions.

This program works great, however, it's showing angles in radians. It might be because you're using the convert_polar function which is based in rad. Is there a way to modify it so that it uses the system's preferred angle output? I mostly need my angles in degrees.

Thank you!
03-31-2020, 04:38 PM (This post was last modified: 03-31-2020 04:42 PM by victorvbc.)
Post: #11
 victorvbc Member Posts: 71 Joined: Jun 2019
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
(03-31-2020 04:22 PM)Dands Wrote:  This program works great, however, it's showing angles in radians. It might be because you're using the convert_polar function which is based in rad. Is there a way to modify it so that it uses the system's preferred angle output? I mostly need my angles in degrees.

Thank you!

The function is defined right under the main program. It uses the modulus and argument commands, which should function according to the system angle setting.

Are you sure you switched it right? The calc. should have a <° symbol on the top right corner. On mine it works as expected, outputs a float in degrees.

If you check the variable 'HAngle', it should return 1.
03-31-2020, 08:14 PM (This post was last modified: 03-31-2020 08:16 PM by Dands.)
Post: #12
 Dands Member Posts: 57 Joined: Jul 2015
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
(03-31-2020 04:38 PM)victorvbc Wrote:
(03-31-2020 04:22 PM)Dands Wrote:  This program works great, however, it's showing angles in radians. It might be because you're using the convert_polar function which is based in rad. Is there a way to modify it so that it uses the system's preferred angle output? I mostly need my angles in degrees.

Thank you!

The function is defined right under the main program. It uses the modulus and argument commands, which should function according to the system angle setting.

Are you sure you switched it right? The calc. should have a <° symbol on the top right corner. On mine it works as expected, outputs a float in degrees.

If you check the variable 'HAngle', it should return 1.

I think something weird is happening, probably because you used the simplify command in the output. I removed it and it persisted, so I'm clueless. Both of these should provide an angle of 45deg. I think it is not handling it properly when coefficients a and b are not integers.

Also, is it normal to see the terminal showing so many alerts?

03-31-2020, 09:16 PM (This post was last modified: 03-31-2020 09:19 PM by victorvbc.)
Post: #13
 victorvbc Member Posts: 71 Joined: Jun 2019
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
(03-31-2020 08:14 PM)Dands Wrote:  I think something weird is happening, probably because you used the simplify command in the output. I removed it and it persisted, so I'm clueless. Both of these should provide an angle of 45deg. I think it is not handling it properly when coefficients a and b are not integers.

Also, is it normal to see the terminal showing so many alerts?

That is quite weird... I guess the CAS doesn't like converting angles from floating point complex numbers to degrees. Anyway, here's a quick & dirty fix:

Code:
 //This program takes an expression or matrix and turns it into polar coordinates #cas toPolar(z):=  BEGIN LOCAL sizes,j,k; IF type(z)=DOM_LIST THEN //check if is list/matrix   sizes:=SIZE(z); //get dimension of rows and columns   IF size(sizes)=1 THEN //row vector     FOR j FROM 1 to sizes DO       z[j]:=convert_polar(z[j]); //convert each element to polar     END;   ELSE //column vector or matrix     FOR j FROM 1 to sizes(1) DO       FOR k FROM 1 to sizes(2) DO         z[j,k]:=convert_polar(z[j,k]); //convert each element to polar       END;      END;   END; ELSE   z:=convert_polar(z); //single element END; RETURN z; END; convert_polar(x):= BEGIN   IF type(IM(x))=DOM_FLOAT OR type(RE(x))=DOM_FLOAT THEN     x:=exact(x);       RETURN approx({ABS(x),ARG(x)});   ELSE     RETURN {ABS(x),ARG(x)};   END; END; #end

It works for that case now. I don't know about the errors, I didn't get them.

04-01-2020, 05:52 AM
Post: #14
 Dands Member Posts: 57 Joined: Jul 2015
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
(03-31-2020 09:16 PM)victorvbc Wrote:
(03-31-2020 08:14 PM)Dands Wrote:  I think something weird is happening, probably because you used the simplify command in the output. I removed it and it persisted, so I'm clueless. Both of these should provide an angle of 45deg. I think it is not handling it properly when coefficients a and b are not integers.

Also, is it normal to see the terminal showing so many alerts?

That is quite weird... I guess the CAS doesn't like converting angles from floating point complex numbers to degrees. Anyway, here's a quick & dirty fix:

Code:
 //This program takes an expression or matrix and turns it into polar coordinates #cas toPolar(z):=  BEGIN LOCAL sizes,j,k; IF type(z)=DOM_LIST THEN //check if is list/matrix   sizes:=SIZE(z); //get dimension of rows and columns   IF size(sizes)=1 THEN //row vector     FOR j FROM 1 to sizes DO       z[j]:=convert_polar(z[j]); //convert each element to polar     END;   ELSE //column vector or matrix     FOR j FROM 1 to sizes(1) DO       FOR k FROM 1 to sizes(2) DO         z[j,k]:=convert_polar(z[j,k]); //convert each element to polar       END;      END;   END; ELSE   z:=convert_polar(z); //single element END; RETURN z; END; convert_polar(x):= BEGIN   IF type(IM(x))=DOM_FLOAT OR type(RE(x))=DOM_FLOAT THEN     x:=exact(x);       RETURN approx({ABS(x),ARG(x)});   ELSE     RETURN {ABS(x),ARG(x)};   END; END; #end

It works for that case now. I don't know about the errors, I didn't get them.

Works great now. Thanks a lot. Still hoping it gets officially implemented in the future though.
04-05-2020, 01:35 PM (This post was last modified: 04-05-2020 02:29 PM by compsystems.)
Post: #15
 compsystems Senior Member Posts: 1,342 Joined: Dec 2013
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
Another request

The imaginary unit i is used like z = a+b*i in general mathematics, however, sometimes j is used as an imaginary unit in the electricity or magnetism classroom because the symbol i has the meaning of current. The imaginary unit may be changed to j on the Imaginary Unit setting screen in System application on casio classPad

Even the character i must be free to be used as a counter variable, therefore another unicode character is required to show (i, e), this will help us to use the i, j counters of the for loops
04-13-2020, 12:23 AM
Post: #16
 CyberAngel Member Posts: 296 Joined: Jul 2018
RE: (Feature Request) - Convert to polar (phasor) notation in CAS
(04-05-2020 01:35 PM)compsystems Wrote:  Another request

The imaginary unit i is used like z = a+b*i in general mathematics, however, sometimes j is used as an imaginary unit in the electricity or magnetism classroom because the symbol i has the meaning of current. The imaginary unit may be changed to j on the Imaginary Unit setting screen in System application on casio classPad

Even the character i must be free to be used as a counter variable, therefore another unicode character is required to show (i, e), this will help us to use the i, j counters of the for loops

There is a special character for the imaginary 'i' with a dedicated key [ Shift] [ 2 ].
Another character is needed for the new imaginary 'j'.
Perhaps HOLDING DOWN the [ Shift ] key would do it?
Reintroducing an old HP 50g concept: shift levels via hold-the-shift-down
and an extra parameter for the
- -
VPN
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)