04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

122<br />

In multiplication, grouping doesn’t matter, so you don’t need parentheses in this case<br />

either:<br />

(a * b) * c = a * (b * c) = a * b * c<br />

Non-associative property<br />

Most of your expressions will be non-associative, <strong>and</strong> will therefore require grouping. In<br />

the examples in the following list, notice how the placement of the parentheses changes<br />

the value of the expression. (Remember, what’s between the parentheses is evaluated<br />

first.) Please also note that the operator != means “does not equal.”<br />

(a * b) + c != a * (b + c)<br />

(4 * 5) + 6 = 26<br />

4 * (5 + 6) = 44<br />

4 * 5 + 6 = 26 (Multiply first, <strong>and</strong> then add)<br />

(a – b) – c != a – (b – c)<br />

(8 – 5) – 4 = –1<br />

8 – (5 – 4) = 7<br />

8 – 5 – 4 = –1 (Solved from left to right)<br />

When in doubt, use parentheses to group; it can never hurt.<br />

Distributive property<br />

When multiplying an expression involving addition or subtraction (which is just addition of<br />

a negative number) by another value, you need to multiply all the different elements in<br />

the expression by the value, as the following three examples show:<br />

4 * (a + b) = 4a + 4b<br />

–(a + b) = –1(a + b) = –1a + –1b<br />

6 * (a + b – c + d) = 6a + 6b – 6c + 6d<br />

You can use the distributive property to multiply two binomials, as shown following:<br />

(2x + 3) * (3x – 2)<br />

= (2x * 3x) + (2x * –2) + (3 * 3x) + (3 * –2)<br />

= 6x 2 + 5x – 6<br />

This is a second-degree polynomial, or a quadratic equation.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!