Project 4: Sum of Polynomials
Application: Suppose two boys decide to throw a rock in the air. The first boy (Adam) is standing on a platform that is 12 feet off the ground. The second boy (Blake) is standing on the ground.
The height of Adam's rock can be expressed as: y = -x^2 +4x + 12 (where x is time in seconds after the throw and y is the height of the rock in feet)
The height of Blake's rock can be expressed as: y = -x^2 + 6x (where x is time in seconds after the throw and y is the height of the rock in feet)
To know how much higher Adam's rock is compared to Blake's rock we could subtract the two polynomials above:
Difference in Height = ( -x^2 +4x + 12 ) - (-x^2 + 6x)
Simplified this would be written as -x^2 +4x + 12 + x^2 - 6x = -2x + 12
Therefore, the difference in the height of the rocks (Adam's - Blake's) can be expressed as Diff = -2x + 12
Adam's Rock Height: H = -x^2 +4x + 12
Blake's Rock Height H = -x^2 + 6x
Difference = -2x + 12
Explanation:
At X = 0, Adam's rock is at height 12 feet
At X = 0, Blake's rock is at height 0 feet
At X = 0, -2(0) + 12 = 12 which is the difference in the heights (12 - 0)
At X = 2, Adam's rock is at height 16 feet
At X = 2, Blake's rock is at height 8 feet
At X = 2, -2(2) + 12 = 8 which is the difference in the heights (16- 8)
Webster's Definition of a Polynomial: a mathematical expression of one or more algebraic terms each of which consists of a constant multiplied by one or more variables raised to a nonnegative integral power (such as a + bx + cx2)
We can perform operations such as addition, subtract, and multiplication of polynomials.
Example of Polynomial Addition:
(3 + 4x + x^2) + (2 + 3x^2 - 4x^3) = 5 + 4x + 4x^2 - 4x^3
Project 4: Variables 'co' and 'co2' have been initialized. These arrays represent the coefficients of two polynomials.
Task: To correctly assign the value of an array called 'sum' which corresponds to the sum of the polynomials with coefficients 'co' and 'co2'.
How to add to an array:
x.push(3);
x.push(5);
x.push(4 + 4);
//x would store the array [3,5,8]. The push command adds the value to the end of the array.
**If your code works for 5 test cases in a row, you can enter your e-mail address.
Universal Computational Math Methods:
pow(5,2) returns 25.0
abs(-3.0) returns 3
sqrt(49.0) returns 7.0