Calculus Questions: Missing Argument, & Derivative of log(x) vs. ln(x)

I am in the Fundamental Math for Data Science course, Differential Calculus section, in the quiz section (Limit Definition of the Derivative Exploration), questions 2 and 3.

Question 2:

In , there are three functions predefined for you:

  • f1() — which defines f1(x) = sin(x)
  • f2() — which defines f1(x) = x^4
  • f3() — which defines f1(x) = x^2*log(x)

Using the limit_derivative() function, calculate the derivative of f3 at x=1 using the following values of h:

  • h=2
  • h=0.1
  • h=0.00001
f3(x) = x^2*log(x)
def f3(x):
    return pow(x, 2) * log(x)

Make sure to print out the values. What number does the limit derivative appear to be approaching?

End of question 2

The answer to h=2 above is print(limit_derivative(f3, 1, 2)). What I don’t understand is how we can put f3 directly as the first argument without its own argument. The function f3 has a parameter x so how can we not provide an argument in f3? I thought if you define a function with a parameter you have to put in an argument where the parameter is defined…?

My second question is question 3 below. This is totally bewildering to me.

Question 3:
You should have the following output in your terminal:
Verify calculation by evaluating the derivative of f3 mathematically. Click the hint if you get stuck.

End of question 3


Use the product rule:
(d/dx) x^2 * log(x) = x^2 * (1/x) + log(x) * 2x

f3’(1) = 1

What I don’t understand is that the above answer is saying that the derivative of log(x) is (1/x), but that is not the derivative of log(x). (1/x) is the derivative of ln(x). The derivative of log(x) is (1/xln10). If the answer didn’t match up with the Python answer I would have assumed this was a typo. But now I am totally confused, because the answers do match up.

Thanks in advance for any help you can provide.


EDIT: Okay, I think I figured out my second question. It looks like it’s due to the fact that the Python function log(x) is not actually log(x) but ln(x). If you want log(x) you have to write log(x, 10). Well that might be the most counter-intuitive thing I’ve ever seen. Codecademy, please add this explanation to the course because it was not obvious at all. Earlier in the course you wrote log(x) with the assumption of base 10.
I am still confused on my first question above.

Functions can be arguments for a function.

It’s possible the other arguments of limit_derivatives are then used as arguments for function f within the limit_derivatives function.

Here’s an example of such a thing:

# average rate of change of function f on interval [a, b]
def avg_rate_of_change(f, a, b):
  # parameter   f is a function
  # parameters  a and b are used as arguments for f
  return (f(b) - f(a)) / (b - a);
guess for limit_derivative function
# to approximate derivative of f at x = a
def limit_derivative(f, a, h):
  return (f(a + h) - f(a)) / h;

And yes,
the log function of Python’s math module does ln (meaning natural logarithm) if there’s no second argument.
the log10 function of Python’s math module does log (as in logarithm base 10).

1 Like