HP Forums
Converting Polar and Rectangular - 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: Converting Polar and Rectangular (/thread-18328.html)



Converting Polar and Rectangular - IsaiahG0701 - 05-05-2022 05:05 AM

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;


RE: Converting Polar and Rectangular - matalog - 05-05-2022 02:30 PM

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.


RE: Converting Polar and Rectangular - Didier Lachieze - 05-05-2022 04:07 PM

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.