# KinderCalculus/syntax

## Fences

aka. "Layer Vision", aka. syntax, aka. order of operation, is the ability to correctly see the order of operation. Associativity is a special case of Layer Vision with verb purity -- that is all + verbs or all * verbs. The following explains to students the necessity of Layer Vision.

Fences are shapes or parentheses marks that define the span of a layer.

${\displaystyle (\ )\ \ \ {\Bigg (}\qquad {\Bigg )}}$

Take a look at the phrase

${\displaystyle \left(\left({\frac {((4\times x)+1)}{3}}\right)^{2}-5\right)}$

When we do arithmetic, we work from the innermost layer outwards. The fences tells us to start with x. Working outward, we times 4, then add 1, then divide by 3, then self-times 2, then minus 5. But as you can see, a lot of fences can clutter up the phrase. We'd rather write

${\displaystyle \left({\frac {4x+1}{3}}\right)^{2}-5}$

and have set rules to tell us the layering order. This is "layer vision" -- the ability to see the layers even when fences and verbs are invisible.

It's important to get the layering right because an incorrect reading of the layers will give wrong answers. For example, 4*5+1 may be read as (4*5)+1 or 4*(5+1). If we chose the wrong layering, we may answer 24 instead of 21.

When parentheses become too cluttered, we can also use shapes.

## Invisible Verbs

Often expressions can be really cluttered such as

${\displaystyle {\frac {-b+(((b^{2})-(4\times (a\times c)))^{1/2})}{(2\times a)}}}$

We would like to write cleaner expressions so we make the following noun-placement rules that makes a verb invisible.

 plus self-plus self-times on fractions, ${\displaystyle 4+{\frac {1}{2}}=4{\tfrac {1}{2}}}$ on variables and layers, ${\displaystyle 4x=4\times x}$ on variables and layers, x^3 = x3

With verbless & fenceless notation, the messy expression above rewrites as the cleaner standard quadratic formula.

## Invisible Fences

Here are the standard rules, in authoritative pecking order, that defines fenceless layering:

 symbol rule / note example Layering marks - (fences, fraction bars, square root bars, functions...) fences - no brainer. Functions also have fences marking its input noun. These fences mark the nouns so that the rules below can go fenceless. fraction bars mark the span of the top & bottom layer as the span of the left and right tips of the fraction bars square root bars (eg. right divide) marks its noun by covering it examples ... self-times rule is ... ab2 should be read as a(b)2, not as (ab)2 self-plus rule is ... ab+1 should be read as (ab)+1, not as a(b+1) plus note ... ...

With these fenceless & verbless invisibility rules, the nasty phrase above becomes a cleaner

${\displaystyle {\frac {-b+{\sqrt {b^{2}-4ac}}}{2a}}}$

## Syntax diagram

Mathematical expressions have a syntactic structure that can be drawn as a "branch". For example,

                                                                               .
3             3                                     .
3  3            \           /                                      .
a  b      is      ^ -- * -- ^                                       .
/           \                                      .
a             b                                     .
.
and                                                                            .
.
a                                                  .
3            \                                                 .
(ab)      is      * -- ^ -- 3                                      .
/                                                 .
b                                                  .
.


In this diagram, the first operations (inner layers) are leaf nodes while the later operations (outer layer) are the inner nodes. This diagram will come in handy as we consolidate the many algebraic operations (see section on algebraic identities).

## Exercises

Show the layering ordering, substitute shapes & variables with the indicated numbers, and reduce.