Product Rule and Trigonometric Derivatives

Problem #89

Tags: calculus

Who solved this?

Previous:24-Bit Bitmaps Next:Binary Numbers


In the previous problem we learned how to compute the exact derivative for any polynomial function. Now we will learn how to compute the exact derivative for various trigonometric functions, and also for more complicated functions.

Before we do, let's take a moment to learn a new notation for denoting dervatives. As calculus was being developed by Newton and Leibniz in the 16th century, the two mathematicians also developed two new notation systems to describe the new concepts. Newton used a prime mark notation which we observed in the previous problem, but Leibniz used a notation involving the term d/dx which behaves as it's own distinct operation, differentiating any term it would appear to "multiply" with. It is most common to see the d/dx term either at the beginning or the end of the function. And so if we take the function f(x) = x^2, then

$$ \Large \frac{d}{dx} x^{2} = x^{2} \frac{d}{dx} = f' (x) = 2x $$

Both notations are widely used interchangeably, and so it is good to be familiar with both.

Unlike the derivatives of the polynomials, the derivatives of the trigonometric functions produce further trigonomeric functions, resulting in a sort of beautiful cyclic symmetry.

$$ \Large \frac{d}{dx} \sin(f(x)) = f'(x) \cdot \cos(f(x)) $$ $$ \Large \frac{d}{dx} \cos(f(x)) = -f'(x) \cdot \sin(f(x)) $$

For example...

$$ \Large \frac{d}{dx} \sin(2x) = 2 \cos(2x) $$ $$ \Large \frac{d}{dx} \cos(3x^{2}) = -6x \sin(3x^{2}) $$

Also, we will learn how to compute derivatives for more complicated functions, specifically those which can be broken down into the product of sub-functions. For some function f(x) which can be written as the product of g(x) and h(x), then the derivative of f(x) can be obtainer by the following Product Rule:

$$ \Large f(x) = g(x) \cdot h(x) $$ $$ \Large f'(x) = g'(x) \cdot h(x) + g(x) \cdot h'(x) $$

Problem Statement

Input Data
The first line will be a single value x0.
The second line will be an integer Q, the quantity of testcases.
Q lines will then follow, each with a function involving sines, cosines, and polynomials.

Answer
Should consist of Q space-separated values corresponding to the derivative of each function at x = x0.
Error should be less than 1e-6.

Example

input data:
12.345
2
-1.234 * x ^ -0.987 * sin(0.123 * x ^ 0.789) + -9.876
1.357 * x ^ 0.234 * cos(0.987 * x ^ 0.654) + 0.001

answer:
0.002739 0.628076
You need to login to get test data and submit solution.