PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Input:
1. A (mathematical) function in terms of x
(Use brackets for best results)
2. A value for x where you want a tangent to be drawn
Sample input:
x**2
2
"""
from sympy import *
import matplotlib.pyplot as plt
import numpy as np
from math import e,pi
x=Symbol("x")
function=eval(input())
function=str(function).replace("x","(x)")
x_value=eval(input())
y_value=eval(str(function).replace("x",str(x_value)))
d_dx=eval(str(diff(function)).replace("x",str(x_value)))
c=-(d_dx*x_value)+y_value
x_list1=np.linspace(x_value-2.5,x_value+2.5,121)
x_list2=np.linspace(x_value-2,x_value+2,2)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run