MAT421 - Lab 1b


In [1]:
%matplotlib notebook
#init_session(use_unicode=True)
from __future__ import division
from sympy import *
x, y, z, t = symbols('x y z t', real=True)
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)
init_printing()

To run a cell: Shift+Enter.

To print:

  • Cell > Run All.
  • Make sure no there is no error.
  • File -> Print Preview.

Print your name using print function.

Example: print("Ali bin Ahmad")


In [ ]:

Print your student id using print function.


In [ ]:

Sketch the graph of $\displaystyle f(x) = \frac{x}{x+2}$.

Define function f.

Example: f = x + 4


In [ ]:

x-intercepts. When $y=0$, $x=?$

Use function solve (Sympy Docs pg. 1462).


In [ ]:

x-intercept:

Answer:

y-intercepts. When $x=0$, $y=?$

Use function subs (Sympy Docs pg. 15).


In [ ]:

y-intercept:

Answer:

Critical Value(s)

Find the first derivative, $f'(x)$, and assign it to variable called f1.

Use function diff (Sympy Docs pg. 37).

Print f1 using function pprint (Sympy Docs pg. 22).


In [ ]:

Make the denominator the same using together function. Assign the result back to function f1. Print f1 using pprint.

Use function together (Sympy Docs pg. 23).


In [ ]:

Solve $f'(x)=0$.

Use function solve (Sympy Docs pg. 1462).


In [ ]:

But, the function does not exist if the denominator is equal to zero.

Solve for the denominator equal to zero.

Use function solve (Sympy Docs pg. 1462).


In [ ]:

Critical value:

Answer:

Interval of decreasing/increasing.

$f'(x<c)$


In [ ]:

The function is

Answer:

$f'(x>c)$


In [ ]:

The function is

Answer:

Maximum or Minimum point

Find the second derivative, $f''(x)$, and assign it to variable called f2. Print f2.


In [ ]:

Find the value of $f''$ at the critical value.
Note: zoo means undefined.


In [ ]:

Extremum point:

Answer:

Concavity

Solve the second derivative equation for $x$.

Use function solve (Sympy Docs pg. 1462).


In [ ]:

$f''(x < c)$

Use function subs (Sympy Docs pg. 15).


In [ ]:

The function is

Answer:

$f''(x > c)$


In [ ]:

The function is

Answer:

Horizontal Aymptote

Limit as f approaches positive infinity.

Use limit function (Sympy Docs pg. 41).


In [ ]:

Limit as f approaches negative infinity.

Use limit function (Sympy Docs pg. 41).


In [ ]:

Horizontal asymptote:

Answer:

Vertical Asymptote

Limit from the left and the right of the critical value that comes from where the function is undefined.

Limit from left.

Use limit function (Sympy Docs pg. 41).


In [ ]:

Limit from right.

Use limit function (Sympy Docs pg. 41).


In [ ]:

Plot the function

Use function plot to plot the function (Sympy Docs pg. 1264).

Set the limit for y-axis from -6 to 10 by adding ylim parameter.


In [ ]: