Post Reply 
Converting Polar and Rectangular
05-05-2022, 05:05 AM
Post: #1
Converting Polar and Rectangular
I’m having trouble downloading a certain program for my hp prime. Every time I type in the programs below I get a syntax error. Is there anyone that has a link where I can download these programs rather than manually put them in?

P_to_R(r,a):=
BEGIN
return (r*COS(a)+r*SIN(a)*i);
END;

R_to_P(x,y):=
BEGIN
return (CAS(collect(ABS(x+y*i)))+"∡"+CAS(collect(ARG(x+y*i))));
END;
Find all posts by this user
Quote this message in a reply
05-05-2022, 02:30 PM
Post: #2
RE: Converting Polar and Rectangular
Should the programs not start with

EXPORT P_2_R(x,y)

Or something instead of your first lines?

If you try it on a calculator, it will tell you where the problem is, by clicking Info after running the program, or clicking Check, when in writing the program.
Find all posts by this user
Quote this message in a reply
05-05-2022, 04:07 PM (This post was last modified: 05-05-2022 04:20 PM by Didier Lachieze.)
Post: #3
RE: Converting Polar and Rectangular
These are CAS programs, you need to add #cas and #end statements:

Code:
#cas
P_to_R(r,a):=
BEGIN
return (r*COS(a)+r*SIN(a)*i);
END;

R_to_P(x,y):=
BEGIN
return (CAS(collect(ABS(x+y*i)))+"∡"+CAS(collect(ARG(x+y*i))));
END; 
#end

Btw, you can use instead of these programs the built-in functions rectangular_coordinates() and polar_coordinates() as explained here.
Find all posts by this user
Quote this message in a reply
Post Reply 




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