# B How to build an equation or expression?

Tags:
1. Jul 15, 2017

### pairofstrings

Hello.
I want to be able to create any mathematical equation or expression. So, one thing I want to confirm is that, to create any complex equation or expression, I should make use of Order of Operation - PEDMAS or BODMAS. Correct? The Order of Operation governs the result, and the Order of Operation is the way by which any complex equation or expression is created.

For example:
y = 4x2 + √16 + (x + 2)

The above equation is built by having BODMAS or PEDMAS in mind, because when I try to get the value of 'y' at a value of 'x' (when plotting graph), I could follow the Order of Operation to arrive at a result, i.e, by a well-defined rule - like BODMAS or PEDMAS. Correct?

Thanks.

Last edited: Jul 16, 2017
2. Jul 15, 2017

### phinds

I don't understand what you mean by "create any mathematical equation or expression"

3. Jul 15, 2017

### pairofstrings

In my first post, I have said a statement that y = 4x2 + √16 + (x + 2). This is a mathematical equation. Correct? Is "create" not a correct word to say in this context?

4. Jul 15, 2017

### phinds

Yes, but it sounds like you mean you want to develop an algorithm that creates ...

I still do not understand what your goal is. Do you mean that you are just trying to figure out what the correct form is for equations in general?

5. Jul 15, 2017

### pairofstrings

Okay. I think, the correct word has to be 'build'. Correct?
I am not able to understand - why do I need to know if an equation has a correct form or not - an equation or expression can be anything, just like music - a thought. Correct? Why should an equation or expression have correct form? What is the meaning of 'correct form'? One thing that comes to my mind is 'generics'. Is this what 'correct form' mean?

I want to confirm whether my approach is correct, to build any equation or expression - the approach is to conform to PEDMAS or BODMAS. So, do I have a correct approach? Please let me know.

Last edited: Jul 15, 2017
6. Jul 15, 2017

### Staff: Mentor

Ipad / iPhone has this app that did what you say:

7. Jul 15, 2017

### FactChecker

Yes, use the rules of operator priority. Using the rules lets everyone know what order the operations should be done in. When in doubt, use parentheses. Don't use them all the time because there will be a clutter of parentheses, but use them when you think there may be some doubt about the order of the operations.

8. Jul 16, 2017

### Staff: Mentor

Programmers use parentheses extensively and about the only time we don't is when the expression is simply +, -, *, and / operations all other operators are suspect and we are never sure of the precedence from memory (ie there are variations between operator meaning and precedence that can inject a bug if you forget which one you're using).

9. Jul 17, 2017

### jbriggs444

The rules for Order of Operation governs how to take a expression that you are given and determine how to evaluate it. In some contexts this is referred to as parsing the expression. The later term comes from the fact that "parsing" amounts to splitting something up into parts.

Generally speaking, parsing something to determine what it means is more difficult than starting with the meaning and constructing an expression that matches that meaning.

If you want to add 2, 2 and 3, you can write 2+2+3. But addition is normally understood as a binary operation. We have three numbers here. Did you mean to take 2+2 and add 3 to that? Or did you mean to take 2+3 and that to 2?

10. Jul 17, 2017

### Staff: Mentor

PEDMAS and BODMAS (synonomous acronyms) are conventions by which any two people who are cognizant of these conventions arrive at the same value for some expression.
The above could be simplified to $y = 4x^2 + 4 + x + 2$, which can be simplified further to $y = 4x^2 + x + 6$. No parentheses are needed.
PEDMAS dictates that we raise x, not 4x, to the power 2, and that we multiply $x^2$ by 4 rather than, say, multiply $x^2 + x + 6$ by 4.
Without these conventions, we would have to explicitly indicate which operations should be performed first. Without PEDMAS (or BODMAS), your equation would need to be $y = ((4 \cdot (x^2)) + x) + 6$.

11. Jul 17, 2017

### Staff: Mentor

Small technical comment:
As $((4 \cdot (x^2)) + x) + 6 = (4 \cdot (x^2)) + (x + 6)$, the outermost bracket could be dropped: $(4 \cdot (x^2)) + x + 6$
This uses the associativity of addition.

12. Jul 17, 2017

### pairofstrings

I am talking about both Parsing Expressions and Constructing Expressions.
Okay, so, 'parsing' is done to understand how an expression has to be evaluated.

I thought, the above equations are the result of applying PEDMAS.

Last edited: Jul 17, 2017
13. Jul 17, 2017

### Staff: Mentor

They are not the result of applying PEDMAS. That would reverse the logic.
You apply PEDMAS to read these expressions.

Where does the expression come from? Someone made it up. Why exactly this expression? We don't know. And it is just an example here anyway.

14. Jul 17, 2017

### pairofstrings

I think that, whether I am reading an expression or writing an expression, the expression has to follow PEDMAS - to make sense and that everyone understands it, and this is how I do it: y = $((4 \cdot (x^2)) + x) + 6$. Correct? PEDMAS is a rule that governs how to evaluate an expression. No?

Last edited: Jul 17, 2017
15. Jul 17, 2017

### Staff: Mentor

You can take every expression and evaluate it using PEDMAS (assuming you don't have things like unpaired brackets or other wrong syntax.
It is just a rule how to read things. Like "read from left to right" for English.

16. Jul 17, 2017

### pairofstrings

Okay, in the above equation, it is implicitly understood that 4 has to be multiplied by x2 and not with the other terms of the equation? In the same manner the rest of the terms in the equation are understood and I do not need to explicitly state the details in the form of parenthesis?

17. Jul 17, 2017

### Staff: Mentor

PEDMAS tells you that.
Right.

18. Jul 17, 2017

### Staff: Mentor

It's not clear to me, nor do I think it's clear to the others responding here why you are asking these questions. The order of operations dictated by PEDMAS/BODMAS are conventions we use when we want to communicate some algebraic expression or equation. Someone long ago decided that for an expression such as $4 \cdot 2 + 5$, an answer of 13 was more reasonable than an answer of 40. @mfb's additional example of reading from left-to-right (in English and many other languages) but right-to-left in some other languages are likewise just conventions.