The following warnings occurred:
Warning [2] Undefined array key 255029 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 255029 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





Rectangular to Polar, Polar to Rectangular – One more time



#2

I realize that Marcus' post regarding returning multiple values to the stack was probably more proof-of-concept than implementation of a useful rectangular to polar conversion function, but I was intrigued, so I pursued it. My first thought was that Marcus’ program did the conversion assuming the imaginary component in stack-1 and the real component in stack-2, while I prefer to assume real in stack-1 and Imaginary in stack-2. Changing Marcus’ program to do that would be easy to do if SWAP were a command, but as discussed in Marcus’ thread, it is not. Using commands that appear to be available, I came up with the following (I used reserved complex variable Z1 instead of temp):

Rectangular to Polar:

EXPORT RtoP;
KEY K_Mul()
BEGIN
"i * + i / CONJ 'Z1' |> ARG Z1 ABS"
END;

Dividing by i and then taking the conjugate swaps the components in the complex number. This seemed to work, so then I turned my attention to Polar to Rectangular conversion, with the magnitude assumed in stack-1 and the angle in stack-2. I figured I’d need two real variables, so I used reserved X and Y. Here is how I did it:

Polar to Rectangular:

EXPORT PtoR;
KEY K_Div()
BEGIN
" 'X' |> X - + 'Y' |> SIN X * Y COS X * "
END;

The “'X' |>” stores the magnitude in X, then to get the angle from stack-2, I recalled the magnitude, subtracted from itself to get zero, then added zero to the angle to drop it to stack-1. Then I could store it in Y and proceed with multiplying the magnitude by the SIN and COS of the angle. Kind of clunky, but it seems to work.

To recap the usage, for rectangular to polar, with the imaginary component in stack-2 and the real component in stack-1, press shift-help (User), then x (multiply). This puts the command string in the command line, then press ENTER and the angle will be returned to stack-2 with the magnitude in stack-1. So it takes four keystrokes to convert from rectangular to polar. This compares to 12 keystrokes for the conversion using my separate MA and AN programs. (Alpha Alpha M A Enter shift + Alpha Alpha A N Enter)

For Polar to rectangular, with the angle in stack-2 and the magnitude in stack-1, press shift-help (User), then / (divide). This puts the command string in the command line, then press ENTER and the imaginary will be returned to stack-2 with the real in stack-1. Again, four keystrokes compared to 12 for conversion using separate IG and RL programs. (Alpha Alpha I G Enter shift + Alpha Alpha R L Enter)

Again, the above is mostly proof-of-concept, done primarily to see if it could be done, like climbing Mt. Everest (with a much, much lower chance of dying in the process.)


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP 35s polar/rectangular conversion CD Dodds 6 2,597 11-28-2013, 02:39 PM
Last Post: Dieter
  [HP Prime]How to get Discrete-Time Fourier Transform uklo 0 1,484 11-18-2013, 08:02 PM
Last Post: uklo
  More programs for polar-rectangular conversion on HP Prime Michael de Estrada 4 1,937 11-04-2013, 12:43 AM
Last Post: Michael de Estrada
  Date/time formats R. Pienne 4 2,164 11-01-2013, 12:43 PM
Last Post: Marcus von Cube, Germany
  How to set the Date.Time etc on a WP34S Harold A Climer 4 1,862 10-29-2013, 09:32 PM
Last Post: FORTIN Pascal
  Prime: Exam mode (possible duplicate after funny response first time) Paul Townsend (UK) 1 1,441 10-24-2013, 03:09 PM
Last Post: Tim Wessman
  Date/time programs for the HP 35s R. Pienne 0 1,067 10-03-2013, 02:37 PM
Last Post: R. Pienne
  OT--Hyperbolic Polar<-->Rectangular Coordinates Matt Agajanian 2 1,177 09-30-2013, 08:53 PM
Last Post: Matt Agajanian
  Nothing like passing the time away... Eddie W. Shore 2 1,360 03-21-2013, 08:23 AM
Last Post: Eddie W. Shore
  New compile-time options for WP-34S Nigel J Dowrick 15 4,591 01-29-2013, 03:25 PM
Last Post: Stephan

Forum Jump: