<< Chapter < Page | Chapter >> Page > |
An expression for the area of a circle
From your earlier coursework, you should know that the area of a circle is given by
A = PI * r^2
where
Proportional to the square of the radius
From this, we can conclude that the area of a circle is not proportional to the radius. Instead, it is proportional to the square of the radius as in
A $ r^2
If you change the radius...
If you change the value of the radius, the area changes in proportion to the square of the radius. If the radius doubles, the area increases by four. If theradius is decreased by 25-percent, the area decreases by more than 25-percent. This is illustrated by the script in Listing 3 .
Listing 3 . Area is proportional to radius squared. |
---|
<!-- File JavaScript03.html --><html><body><script language="JavaScript1.3">var r = 10
var A = Math.PI * Math.pow(r,2)document.write("r =" + r +
", A = " + A + "<br/>")
//Multiply r by 2. Then display r and Cr = r * 2
var A = Math.PI * Math.pow(r,2)document.write("r =" + r +
", A = " + A + "<br/>")//Reduce r by 25%, Then display r and C
r = r * (1 - 25/100)var A = Math.PI * Math.pow(r,2)
document.write("r =" + r +", A = " + A + "<br/>")//Compute and the display the cube root
// of a number.var X = Math.pow(8,1/3)
document.write("Cube root of 8 = " + X)</script></body></html> |
The JavaScript Math.pow method
Listing 3 calls a built-in JavaScript method that I have not used before: Math.pow . This method is called to raise a value to a power. It requires two parameters. The first parameter is the valuethat is to be raised to a power and the second parameter is the power to which the value is to be raised.
The method returns the value raised to the power.
Fractional exponents
Although this topic is not directly related to the discussion on proportionality, as long as I am introducing the method named Math.pow , I will point out the it is legal for the exponent to be a fraction. The last little bit of code in Listing 3 raises the value 8 to the 1/3 power. This actually computes the cube root of the value 8. As you shouldbe able to confirm in your head, the cube root of 8 is 2, because two raised to the third power is 8.
Output from the script
When you open the script shown in Listing 3 in your browser, the text shown in Figure 3 should appear in your browser window.
Figure 3 . Screen output for Listing #3. |
---|
r =10, A = 314.1592653589793
r =20, A = 1256.6370614359173r =15, A = 706.8583470577034
Cube root of 8 = 2 |
An examination of the first three lines of text in Figure 3 should confirm that they satisfy the proportionality rules for the square of theradius described earlier .
The last line of text in Figure 3 confirms that the Math.pow method can be used to compute roots by specifying fractional exponents as thesecond parameter.
I encourage you to run the scripts that I have presented in this lesson to confirm that you get the same results. Copy the code for each script into atext file with an extension of html. Then open that file in your browser. Experiment with the code, making changes, and observing the results of your changes. Makecertain that you can explain why your changes behave as they do.
This section contains a variety of miscellaneous information.
Financial : Although the Connexions site makes it possible for you to download a PDFfile for this module at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should be aware thatsome of the HTML elements in this module may not translate well into PDF.
I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module.
In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.comshowing me as the author. I neither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, pleasebe aware that it is a copy of a module that is freely available on cnx.org and that it was made and published without my prior knowledge.
Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.
-end-
Notification Switch
Would you like to follow the 'Game 2302 - mathematical applications for game development' conversation and receive update notifications?