Arithmetic without parentheses - University of Nebraska at Kearney

Arithmetic without parentheses
Jia Huang
University of Nebraska at Kearney
E-mail address: [email protected]
March 15, 2016
Jia Huang (UNK)
Arithmetic without parentheses
March 15, 2016
1/7
Introduction
Example
48 ÷ 2(9 + 3) = ?
Solution (Google)
=
=
=
48 ÷ 2(9 + 3)
48 ÷ 2(12)
24 × 12
288
Solution (PEMDAS)
=
=
=
48 ÷ 2(9 + 3)
48 ÷ 2(12)
48 ÷ 24
2
Conclusion
An arithmetic expression without parentheses is ambiguous.
Problem
How ambiguous is it?
Jia Huang (UNK)
Arithmetic without parentheses
March 15, 2016
2/7
Subtraction
Example (1)
Example (3)
(a − b) = a − b
((a−b)−c)−d
(a−b)−(c−d)
(a−(b−c))−d
a−((b−c)−d)
a−(b−(c−d))
Example (2)
(a − b) − c = a − b − c
a − (b − c) = a − b + c
=
=
=
=
=
a−b−c
a−b−c
a−b+c
a−b+c
a−b+c
−d
+d
−d
+d
−d
Problem
C. How many ways to insert parentheses in x0 − x1 − x2 − · · · − xn ?
D. How many distinct functions can be obtained from this expression?
Solution (with computer aids)
n
Cn
Dn
1
1
1
2
2
2
3
5
4
Jia Huang (UNK)
4
14
8
5
42
16
6
132
32
Theorem
···
···
···
Arithmetic without parentheses
Cn =
Dn =
1 2n
n+1 n . (see wiki)
2n−1 . (Exercise)
March 15, 2016
3/7
A variation of subtraction
Definition (1)
Example (3)
(a ∗ b) = −a − b
((a ∗ b) ∗ c) ∗ d
(a ∗ b) ∗ (c ∗ d)
(a ∗ (b ∗ c)) ∗ d
a ∗ ((b ∗ c) ∗ d)
a ∗ (b ∗ (c ∗ d))
Example (2)
(a ∗ b) ∗ c = a + b − c
a ∗ (b ∗ c) = −a + b + c
= −a − b + c − d
= a+b+c +d
= a−b−c −d
= −a − b − c + d
= −a + b − c − d
Problem
C’. How many ways to insert parentheses in x0 ∗ x1 ∗ x2 ∗ · · · ∗ xn ?
D’. How many distinct functions can be obtained from this expression?
Solution (with computer aids)
n
Cn0
Dn0
1
1
1
2
2
2
3
5
5
Jia Huang (UNK)
4
14
10
5
42
21
6
132
42
Problem
···
···
···
Arithmetic without parentheses
Cn0 =
Dn0
1 2n
n+1 n
= Cn .
=?
March 15, 2016
4/7
Binary Trees
Definition
A (full) binary tree is a structure in which each node has two children.
The left (right) depth of a node is the number of left (right) steps
from the root down to this node; depth = left depth + right depth.
Fact
Ways to parenthesize x0 ∗ x1 ∗ · · · ∗ xn ⇔ binary trees with n + 1 leaves.
Example
Example
parenthesization
a ∗ ((b ∗ c) ∗ d)
binary tree
a ∗ b = −a + b
a∗b =a−b
a ∗ b = −a − b
−a + b − c + d
a−b+c +d
−a − b − c + d
left depth
right depth
depth
Jia Huang (UNK)
Arithmetic without parentheses
a
b c d
(1, 2, 1, 0)
(0, 1, 2, 2)
(1, 3, 3, 2)
March 15, 2016
5/7
Related Questions
Example (assuming c = d)
((a−b)−c)−d
(a−b)−(c−d)
(a−(b−c))−d
a−((b−c)−d)
a−(b−(c−d))
=
=
=
=
=
a−b−c
a−b−c
a−b+c
a−b+c
a−b+c
−d
+d
−d
+d
−d
= a − b − 2c
=
a−b
=
a−b
= a − b + 2c
=
a−b
Problem
How many distinct functions can be obtained from x0 − x1 − · · · − xn
when x0 , x1 . . . , xn are not all distinct? (e.g., x2 = x5 = x7 , x3 = x4 )
What if we are allowed to permute x0 , x1 , . . . , xn ?
What if we are allowed to use other arithmetic operations (+, ×, ÷)?
What if we are allowed to use other operations (e.g., ab )?
Jia Huang (UNK)
Arithmetic without parentheses
March 15, 2016
6/7
More Examples
Example (Maths24 or The 24 Game)
((3 + 4) + 5) × 2 = 24,
((3 ÷ 3) + 5) × 4 = 24,
?
1 ? 1 ? 1 ? 1 ? = 24
Example (Clocks with 9 only; a mistake in the left one)
Jia Huang (UNK)
Arithmetic without parentheses
March 15, 2016
7/7