<< Chapter < Page Chapter >> Page >

NewWeight / BirthWeight = 2

where the slash character "/" indicates division.

Percentage increases

It is also common for us to talk about something increasing or decreasing by a given percentage value. For example, we might say that a colt increased itsweight by 50-percent in one year. This is equivalent to saying:

NewWeight = BirthWeight * (1 + 50/100)

This assumes that when evaluating a mathematical expression:

  • The asterisk character " * " indicates multiplication.
  • Computations begin inside of the inner-most pair of matching parentheses and work outward from there.
  • Multiplication and division are performed before addition and subtraction are performed.

This is typical behavior for computer programs and spreadsheets, but not necessarily for hand calculators.

Percentage decreases

In my dreams, I might say that I went on a diet and my weight decreased by 25-percent in one year. This would be equivalent to saying:

NewWeight = OldWeight * (1 - 25/100)

Exercise on scale factors

Write a script that has the following behavior. Given a chalk line that is 100 inches long, draw other chalk lines that are:

  • A. Twice the length of the original line.
  • B. Twenty-five percent of the length of the original line.
  • C. Twenty-five percent greater than the length of the original line.
  • D. Twenty-five percent less than the length of the original line.

My version of the script is shown in Listing 1 .

Listing 1 . Exercise on scale factors
<!-- File JavaScript01.html --><html><body><script language="JavaScript1.3">//Do the computations var origLine = 100var lineA = 2 * origLine var lineB = (25/100) * origLinevar lineC = (1 + 25/100) * origLine var lineD = (1 - 25/100) * origLine//Display the results document.write("Original line = "+ origLine + "<br/>") document.write("A = " + lineA + "<br/>") document.write("B = " + lineB + "<br/>") document.write("C = " + lineC + "<br/>") document.write("D = " + lineD + "<br/>")</script></body></html>

Screen output

When you copy the code from Listing 1 into an html file and open the file in your web browser, the output text shown in Figure 1 should appear in your browser window.

Figure 1 . Screen output for Listing #1.
Original line = 100 A = 200B = 25 C = 125D = 75

Note that although they sound similar, specifications B and D above don't mean the same thing.

Proportions

We talk about increasing or changing a value by some factor because we can often simplify a problem by thinking in terms of proportions.

A symbol for proportionality

Physics textbooks often use a character that doesn't appear on a QWERTY keyboard to indicate "is proportional to."

I will use a "$" character for that purpose because:

  • It does appear on a QWERTY keyboard.
  • It isn't typically used in mathematical expressions unless American currency is involved.
  • It is not a JavaScript operator.

For example, I will write A $ B to indicate that A is proportional to B.

When we say that A is proportional to B, or

A $ B

we mean that if B increases by some factor, then A must increase by the same factor.

Circumference of a circle

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Game 2302 - mathematical applications for game development. OpenStax CNX. Jan 09, 2016 Download for free at https://legacy.cnx.org/content/col11450/1.33
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Game 2302 - mathematical applications for game development' conversation and receive update notifications?

Ask