Question about problem set 2 - Problems #2 and #3 - The compute_deriv and compute_root functions. How am I supposed to calculate these functions without an "x" value? According to the comments posted in the code, compute_deriv is only supposed to take the variable (poly) - wouldn't I also need to bring in a value for x as well? Am I just supposed to assign x to a random value inside the function? The commented output in the function makes it looks like x=1. Can anyone explain this? Thanks.
The roots of a functuon are when y=0. So knowing that the ouput of the funtion will be 0, you find the input. |dw:1408985615734:dw| As for the derivative, it is the the rate of change or the slope at a particular point. In a linear equation, this is just a slope. In a non-linear equation, the rate of change is also changing and therefore a calculation. This calculation can be used to find the rate of change at any point given but is still a valid answer in itself.
I'm sure that's a very useful answer for a calculus class, but how to I adjust my code in computer science 6.00 to account for this formula when the function presented doesn't ask for an x variable?
They are asking you to solve a calculus problem with a computer.
Well, one is a claculus problem and one is an algebra problem.
Also, did you look at the example? It might be confusing if toy don't realize they are printing it out in reverse because the position in the tuple relates to the power on the variable. ``` >>> poly = (-13.39, 0.0, 17.5, 3.0, 1.0) # x4 + 3.0x3 + 17.5x2 - 13.39 >>> print compute_deriv(poly) # 4.0x3 + 9.0x2 + 35.0x (0.0, 35.0, 9.0, 4.0) ``` Well, lets look at that more closely. \(4x^3 + 9x^2 + 35^x \) is printing out as (0.0, 35.0, 9.0, 4.0) Well, \(4x^3 + 9x^2 + 35^x \) means \(4x^3 + 9x^2 + 35^x +0x^0\) The 0th power of x has 0 as a constant The 1st power of x has 35 as a constant The 2nd power of x has 9 as a constant The 3rd power of x has 4 as a constant Does the example make more sense now? As you can see, this output is NOT for a specific value of x. It is just a polynomial stored as a tuple.
Join our real-time social learning platform and learn together with your friends!