Calculus

Exercise 1

The derivative of:

$x^3-\frac{1}{x}$
is:

$3x^2-(-1)*\frac{1}{x^2}$

At x = 1 we get y = 0 and a slope for the tangent of 4
The tangent will have an intercept of -4 and an equation of 4x-4

To plot:

def f(x):
return(x**3-1/x)

#div by 0 error at x=0, so we use x=0.1
x = np.arange(0.1, 3, 0.1)
fig = plot(x, [f(x), 4 * x-4], 'x', 'f(x)', legend=['f(x)', 'Tangent line (x=1)'])


The image will be:

To save this image add this line to the beginning of the plot function:

    fig = d2l.plt.figure()


and a return to the end:

    return fig


and this after making the plot:

fig.savefig("2_Prelim 4_Calc 1_Ex.jpg")

1 Like

Exercise 2

$\nabla_{\mathbf{x}}{f(\mathbf{x})=\bigg[6x_1,5e^x_2\bigg]^\top$

1 Like

I appreciate any corrections!

Exercise 3

$\nabla_{\mathbf{X}}||\mathbf{x}||_2=\frac{\mathbf{x}}{||\mathbf{x}||_2}$

Explaination: ${||\mathbf{x}||_2=\sqrt{\mathbf{X}^{\top}{\mathbf{X}}}$

use the chain rule:
${u=\mathbf{X}^{\top}{\mathbf{X}}}$

${\frac{\partial}{\partial{u}}u^\frac{1}{2}.\frac{\partial}{\partial{\mathbf{x}}}\mathbf{X}^{\top}{\mathbf{X}}}$

${(\frac{1}{2}u^{-\frac{1}{2}})(2\mathbf{x})=(\frac{1}{2}\frac{1}{||\mathbf{x}||_2})(2\mathbf{x})=\frac{\mathbf{x}}{||\mathbf{x}||_2}$

Exercise 4

$\frac{\partial{u}}{\partial{a}}=\frac{\partial{u}}{\partial{x}}\cdot\frac{\partial{x}}{\partial{a}}+\frac{\partial{u}}{\partial{y}}\cdot\frac{\partial{y}}{\partial{a}}+\frac{\partial{u}}{\partial{z}}\cdot\frac{\partial{z}}{\partial{a}}$

$\frac{\partial{u}}{\partial{b}}=\frac{\partial{u}}{\partial{x}}\cdot\frac{\partial{x}}{\partial{b}}+\frac{\partial{u}}{\partial{y}}\cdot\frac{\partial{y}}{\partial{b}}+\frac{\partial{u}}{\partial{z}}\cdot\frac{\partial{z}}{\partial{b}}$

1 Like

Your solution is so brief and correct. Thank you