Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Views: 20
Image: ubuntu2204
# Part A: #(a) Finding the limit of the functiom below limit(sin(1/x-2)/(x-2),x=2)
Infinity
#(b) Ploting the function below over the intervals of 1.5,2.5 plot(sin(1/x-2)/(x-2),x,1.5,2.5,ymin=-1,ymax=1)
#(c) Ploting the function below over the intervals of 1.95,2.05 plot(sin(1/x-2)/(x-2),x,1.95,2.05,ymin=-1,ymax=1)
#(d)Yes, the above function dose exist and my answer agrees with (a) #Part B: Plotting (sin(2x)/x and (-cos(x)+3) plot(sin(2*x)/x, x, -1.5, 1.5) + plot(-cos(x) + 3, x, -1.5, 1.5)
# sin(2x)/x <f(x)< -cos(x)+3 Finding limit of f(x) when x approching to 0 from sympy import limit, sin, cos, symbols x = symbols('x') f = (sin(2*x)/x) - cos(x) + 3 limit(f, x, 0)
4
#Part C: #(a) Find the equation of the tangent line to the graph of f(x)=x^3+2x+1 at point (1,4) x = var('x') f(x) = x^3 + 2*x + 1 point = (1, 4) derivative = f.derivative(x) slope = derivative.subs(x=point[0]) equation = slope * (x - point[0]) + point[1] equation
x |--> 5*x - 1
#(b)plottinf f(x)=x63+2x+1 with tangent line to the graph at point (1,4) import numpy as np import matplotlib.pyplot as plt def f(x): return x**3 + 2*x + 1 def tangent_line(x): return 4 + 9*(x-1) x = np.linspace(-5, 5, 100) y = f(x) tangent = tangent_line(x) plt.plot(x, y, label="f(x) = x^3 + 2x + 1") plt.plot(x, tangent, label="Tangent line at (1, 4)") plt.scatter(1, 4, color='red', label="Point (1, 4)") plt.legend() plt.xlabel("x") plt.ylabel("y") plt.title("Plot of f(x) and Tangent Line") plt.grid(True) plt.show()
[<matplotlib.lines.Line2D object at 0x7f4dc03cd190>] [<matplotlib.lines.Line2D object at 0x7f4db820f310>] <matplotlib.collections.PathCollection object at 0x7f4dc040dc10> <matplotlib.legend.Legend object at 0x7f4db81fed50> Text(0.5, 0, 'x') Text(0, 0.5, 'y') Text(0.5, 1.0, 'Plot of f(x) and Tangent Line')
#Part D: (a) Plotting the graph of 1/x^2-4 over the interval [-3.5,3.5]
import numpy as np import matplotlib.pyplot as plt x = np.linspace(-3.5, 3.5, 100) # Create an array of x values y = 1/(x**2 - 4) # Compute the corresponding y values plt.figure(figsize=(6, 6)) # Set the figure size 6x6 inches plt.plot(x, y, 'b-', label='f(x) = 1/(x^2 - 4)') plt.axvline(x=-2, color='r', linestyle='--') # Vertical asymptote x = -2 plt.axvline(x=2, color='r', linestyle='--') # Vertical asymptote x = 2 plt.ylim(-15, 15) # Set the y-axis limits plt.xlabel('x') plt.ylabel('f(x)') plt.title('Graph of f(x) = 1/(x^2 - 4)') plt.legend() plt.grid(True) plt.show()
[<matplotlib.lines.Line2D object at 0x7f4db8037810>] <matplotlib.lines.Line2D object at 0x7f4dc034a210> <matplotlib.lines.Line2D object at 0x7f4db806f350> (-15.0, 15.0) Text(0.5, 0, 'x') Text(0, 0.5, 'f(x)') Text(0.5, 1.0, 'Graph of f(x) = 1/(x^2 - 4)') <matplotlib.legend.Legend object at 0x7f4db81e5290>
#(b)Find fifth derivative of the function. import sympy as sp x = sp.symbols('x') f = sp.diff(1 / (x**2 - 4), x, 5) sp.pprint(f)
-3840*x^5/(x^2 - 4)^6 + 3840*x^3/(x^2 - 4)^5 - 720*x/(x^2 - 4)^4