How can I write complex equations using Reverse Polish notation?

In summary, RPN (Reverse Polish Notation) is a method of simplifying expressions by using operators and operands in a specific order. The expression can be evaluated on an RPN calculator, such as the HP 48, by using operations such as Enter, +, and Sqrt. This method can be used to solve complex equations without needing to remember multiple intermediate results. It involves applying operators to the "thing" immediately before it, with brackets used to clarify the order of operations.
  • #1
Synetos
40
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:
Mathematics news on Phys.org
  • #2
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.
 
  • #3
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
 

Related to How can I write complex equations using Reverse Polish notation?

1. What is Reverse Polish notation (RPN)?

Reverse Polish notation (RPN) is a mathematical notation in which operators follow the operands they operate on. It was developed in the 1920s by Polish mathematician Jan Łukasiewicz and is used as an alternative to the more common infix notation.

2. How does RPN differ from traditional infix notation?

In traditional infix notation, operators are placed between the operands they operate on, which can lead to ambiguity and require the use of parentheses in more complex expressions. In RPN, the operators always come after the operands, making the expression unambiguous and eliminating the need for parentheses.

3. What are the advantages of using RPN?

RPN can simplify and speed up the process of evaluating mathematical expressions, especially those that involve multiple operations and/or parentheses. It also has a consistent and logical structure, making it easier to learn and use compared to traditional infix notation.

4. Are there any disadvantages to using RPN?

One disadvantage of RPN is that it can be challenging for people who are used to traditional infix notation to learn and use. Additionally, RPN is not as widely used as infix notation, so some people may not be familiar with it.

5. How is RPN used in scientific and mathematical applications?

RPN is commonly used in scientific and mathematical applications that involve complex calculations, such as calculators, computer programs, and engineering software. It is also used in some programming languages, such as Forth and PostScript.

Similar threads

Replies
3
Views
915
Replies
13
Views
1K
  • General Math
Replies
11
Views
5K
Replies
9
Views
2K
Replies
16
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
1K
  • Advanced Physics Homework Help
Replies
9
Views
1K
Replies
11
Views
11K
Replies
3
Views
2K
Back
Top