How can I write complex equations using Reverse Polish notation?

2 replies · 3K views · last reply
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:
Integral from 0 to 2 of the square root of (dx/dt) squared plus (dy/dt) squared plus (dz/dt) squared, with respect to t.
 
Last edited:
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:
Integral from 0 to 2 pi of the square root of (dx/dt)^2 + (dy/dt)^2 + (dz/dt)^2 with respect to t, the arc length formula for a space curve.

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:
Integral from 0 to 2π of the square root of (dx/dt)² + (dy/dt)² + (dz/dt)², written as a single mathematical expression.

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