Project 17: Finding X-Intercepts

Suppose we want to find the dimensions of a particular cube that has the following properties:

The length is unknown, so we will call it X.

The width is 3 more than the length (X + 3)

The height is 2 less than the length (X - 2)

The volume of the cube is 200 sq. inches.



V = X(X +3)(X-2) = x^3 + x^2 - 6x

x^3 + x^2 - 6x = 200

To solve this equation, we can write the equation as x^3  + x^2 - 6x - 200 = 0

Now, if we can find the x-intercept of the equation (where x is positive) we find that X = 5.856

So the length is 5.856, the width is 8.856, and the height is 3.856.


Some more examples of finding x-intercepts are shown below:

For the polynomial above, there is one zero (x-intercept) between the values x = -1 and x = 3.  The zero is x = 1.

For the polynomial above, there are two zeros (x-intercepts) between the values x = -4 and x = -1.  The zeros are x = -3 and x = -1.

For the polynomial above, there are no zeros (x-intercepts) between the values x = -1 and x = 0.  

Project 17:

The following variables have been initialized 'lowerX', 'upperX', 'co'.  There is also a working method called getYPoly.

lowerX is the lower bound for the range in which you are searching for an x-intercept.  For the first example above, lowerX is -1.

upperX is the upper bound for the range in which you are searching for an x-intercept.  For the first example above, upperX is 3.

co is an array of values that represent the polynomial's coefficients in ascending order

example: if a polynomial is y = x^3 -  4x^2 - 11x + 30

The array 'co' would hold values: {30, -11, -4, 1}.

getYPoly is a method that accepts an array of coefficients (representing the coefficients of a polynomial) and an x-value.  The method returns the y-value for the polynomial at the given x.

Example:  If 'co' holds the coefficients for the polynomial graphed above, getYPoly(co, 0.0) would return -6.0.

Task:

Appropriately assign the value of 'zero'.  

'zero' should not have a value if there are no x-intercepts between x = lowerX and x = upperX.

'zero' should be assigned to an intercept between x = lowerX and x = upperX if at least one exists.


For the Polynomial shown below (coefficients would be: 0,5,-5,1), and lowerX = 1.0 and upperX = 3.0, zero would be a number close to 1.38. 

**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