Fiche d'exercices Application de la dérivation 634 2015/2016

In [1]:
from sympy import *
init_session()
IPython console for SymPy 1.0 (Python 3.4.3-32-bit) (ground types: python)

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)
>>> init_printing()

Documentation can be found at http://docs.sympy.org/1.0/
In [2]:
import numpy as np
import matplotlib.pyplot as plt
In [3]:
% matplotlib inline
In [46]:
def deriver(exp, ordre = 1):
    return diff(exp, x, ordre)

def simplifier(exp):
    return simplify(exp)
In [34]:
def tracer(exp, xmin, xmax):
    f = lambdify(x, exp, "numpy")
    lesx = np.linspace(xmin, xmax, 101)
    lesy = f(lesx)
    plt.grid(True)
    plt.axhline(0, color='red')
    plt.axvline(0, color='red')
    plt.plot(lesx, lesy)

Exercice 1

In [6]:
fx = x**3 - 3*x**2 - 7*x 
In [7]:
fx
Out[7]:
$$x^{3} - 3 x^{2} - 7 x$$
In [8]:
deriver(fx)
Out[8]:
$$3 x^{2} - 6 x - 7$$
In [16]:
tracer(fx, -4, 4)
In [17]:
gx = (x**2 + 1)*sqrt(x)
In [18]:
gx
Out[18]:
$$\sqrt{x} \left(x^{2} + 1\right)$$
In [19]:
deriver(gx)
Out[19]:
$$2 x^{\frac{3}{2}} + \frac{x^{2} + 1}{2 \sqrt{x}}$$
In [28]:
simplifier(deriver(gx))
Out[28]:
$$\frac{5 x^{2} + 1}{2 \sqrt{x}}$$
In [29]:
tracer(gx, 0, 10)
In [30]:
hx = (x + 4)/x**2
In [31]:
hx
Out[31]:
$$\frac{1}{x^{2}} \left(x + 4\right)$$
In [32]:
deriver(hx)
Out[32]:
$$\frac{1}{x^{2}} - \frac{1}{x^{3}} \left(2 x + 8\right)$$
In [33]:
simplifier(hx)
Out[33]:
$$\frac{1}{x^{2}} \left(x + 4\right)$$
In [35]:
tracer(hx, 0.1, 5)
In [36]:
jx = (3*x - 1)**4
In [37]:
jx
Out[37]:
$$\left(3 x - 1\right)^{4}$$
In [38]:
deriver(jx)
Out[38]:
$$12 \left(3 x - 1\right)^{3}$$
In [40]:
tracer(jx, -2, 3)
In [41]:
kx = sqrt(x)/(x + 6)
In [42]:
kx
Out[42]:
$$\frac{\sqrt{x}}{x + 6}$$
In [43]:
deriver(kx)
Out[43]:
$$- \frac{\sqrt{x}}{\left(x + 6\right)^{2}} + \frac{1}{2 \sqrt{x} \left(x + 6\right)}$$
In [44]:
simplifier(deriver(kx))
Out[44]:
$$\frac{- x + 6}{2 \sqrt{x} \left(x + 6\right)^{2}}$$
In [45]:
tracer(kx, 0, 6)
In [47]:
mx = 3*x**4 + 8*x**3 - 78*x**2 + 120*x - 200
In [48]:
mx
Out[48]:
$$3 x^{4} + 8 x^{3} - 78 x^{2} + 120 x - 200$$
In [50]:
d1mx = deriver(mx, 1)
d1mx
Out[50]:
$$12 x^{3} + 24 x^{2} - 156 x + 120$$
In [51]:
d2mx = deriver(mx, 2)
In [52]:
d2mx
Out[52]:
$$12 \left(3 x^{2} + 4 x - 13\right)$$
In [53]:
tracer(d2mx, -4, 4)
In [55]:
tracer(d1mx, -4, 4)
In [56]:
factor(d1mx)
Out[56]:
$$12 \left(x - 2\right) \left(x - 1\right) \left(x + 5\right)$$
In [57]:
tracer(mx, -4, 4)

Exercice 2

In [58]:
fx = x + 3/x
In [59]:
deriver(fx)
Out[59]:
$$1 - \frac{3}{x^{2}}$$
In [61]:
factor(deriver(fx))
Out[61]:
$$\frac{1}{x^{2}} \left(x^{2} - 3\right)$$
In [63]:
tracer(fx, 0.1, 4)
plt.axvline(np.sqrt(3), color='red')
Out[63]:
<matplotlib.lines.Line2D at 0xa9c1abcc>

Exercice 3

In [64]:
fx = -Rational(2, 3)*x**3 -2*x**2 + 4*x - Rational(1, 3)
In [65]:
fx
Out[65]:
$$- \frac{2 x^{3}}{3} - 2 x^{2} + 4 x - \frac{1}{3}$$
In [66]:
deriver(fx)
Out[66]:
$$- 2 x^{2} - 4 x + 4$$
In [68]:
solve(deriver(fx), x)
Out[68]:
$$\left [ -1 + \sqrt{3}, \quad - \sqrt{3} - 1\right ]$$
In [70]:
tracer(fx, -3, 3)

Exercice 4

In [71]:
hx = (x**2 - 1)/(x**2 + 2)
In [72]:
hx
Out[72]:
$$\frac{x^{2} - 1}{x^{2} + 2}$$
In [73]:
deriver(hx)
Out[73]:
$$- \frac{2 x \left(x^{2} - 1\right)}{\left(x^{2} + 2\right)^{2}} + \frac{2 x}{x^{2} + 2}$$
In [74]:
simplifier(deriver(hx))
Out[74]:
$$\frac{6 x}{\left(x^{2} + 2\right)^{2}}$$
In [75]:
tracer(hx, -2, 2)

Exercice 5

In [81]:
V = symbols('V')
In [82]:
ax = 2*(pi*x**2 + V/x)
In [83]:
ax
Out[83]:
$$\frac{2 V}{x} + 2 \pi x^{2}$$
In [84]:
deriver(ax)
Out[84]:
$$- \frac{2 V}{x^{2}} + 4 \pi x$$
In [85]:
factor(deriver(ax))
Out[85]:
$$\frac{1}{x^{2}} \left(- 2 V + 4 \pi x^{3}\right)$$
In [88]:
s = solve(deriver(ax), x)
In [89]:
s[0] #valeur de x annulant la dérivée et rayon du volume minimal
Out[89]:
$$\frac{2^{\frac{2}{3}} \sqrt[3]{V}}{2 \sqrt[3]{\pi}}$$
In [97]:
#Exemple pour V = 100
ax100 = ax.subs(V, 100)
In [98]:
tracer(ax100, 0.1, 10)

Exercice 8

In [99]:
fx = sqrt(x)/(x + 4)
In [100]:
fx
Out[100]:
$$\frac{\sqrt{x}}{x + 4}$$
In [101]:
deriver(fx)
Out[101]:
$$- \frac{\sqrt{x}}{\left(x + 4\right)^{2}} + \frac{1}{2 \sqrt{x} \left(x + 4\right)}$$
In [103]:
simplifier(deriver(fx))
Out[103]:
$$\frac{- x + 4}{2 \sqrt{x} \left(x + 4\right)^{2}}$$
In [104]:
tracer(fx, 0.1, 16)