How can I write complex equations using Reverse Polish notation?

  • Thread starter Thread starter Synetos
  • Start date Start date
  • Tags Tags
    Notation Reverse
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
Synetos
Messages
37
Reaction score
1
So I need some help with RPN, I checked the wiki page but I still don't quite get it. Like I get simple multiplications, aditions etc. But how would you for example write:
}^{2}%20\sqrt{%20(\frac{dx}{dt})^{2}%20+%20(\frac{dy}{dt})^{2}%20+%20(\frac{dz}{dt})^{2}%20%20}}.png
 
Last edited:
Physics news on Phys.org
Synetos said:
So I need some help with RPN, I checked the wiki page but I still don't quite get it. Like I get simple multiplications, aditions etc. But how would you for example write:
}^{2}%20\sqrt{%20(\frac{dx}{dt})^{2}%20+%20(\frac{dy}{dt})^{2}%20+%20(\frac{dz}{dt})^{2}%20%20}}.png

Let me simplify things a bit, using x', y', and z' for values the derivatives, so that x' means the value of dx/dt at some specific t. Same for y' and z'.

To get the value of the radical you could do this:
x' Enter X2 y' Enter X2 + z' Enter X2 + Sqrt

I'm thinking in terms of how you would evaluate a similar expression on an RPN calculator, such as the HP 48.

In the expression above X2 is the operation that pops the value at the top of the stack, squares it, and stores the squared value at the top of the stack.
Enter is the operation that stores the value preceding it on the stack.
+ is the operation that pops the top two values on the stack, adds them, and stores their sum at the top of the stack.
Sqrt pops the top of the stack, takes the square root of it, and stores that value on the stack top.
 
Synetos said:
So I need some help with RPN, I checked the wiki page but I still don't quite get it. Like I get simple multiplications, aditions etc. But how would you for example write:
}^{2}%20\sqrt{%20(\frac{dx}{dt})^{2}%20+%20(\frac{dy}{dt})^{2}%20+%20(\frac{dz}{dt})^{2}%20%20}}.png

It's the way you'd do it in your head if you didn't want to remember too many intermediate results. There are different things you might want to use as operators, I made it simple with d/dt and integrate. You might instead have a d?/d? operator which takes two parameters, the function and the variable to differentiate with respect to.

Find x
Apply d/dt to it
Square it
Find y
Apply d/dt to it
Square it
Add the results of those two squarings
Find z
Apply d/dt to it
Square it
Add the result of the previous sum to this last result
Square root it
Integrate it

Rewritten in one line it becomes
x d/dt 2 y d/dt 2 + z d/dt 2 + SqRoot Integrate

To interpret that it might be clearer with brackets. Each operator applies to the "thing" immediately before it. Or two things in case of the + operator.
( < [ ((x d/dt)2) ((y d/dt)2) + ] [ (z d/dt)2 ] + >SqRoot )Integrate