Cách lấy đạo hàm trong python

Với sự giúp đỡ của sympy. Derivative(), chúng ta có thể tạo một dẫn xuất chưa được đánh giá của một biểu thức SymPy. Nó có cùng cú pháp với phương thức diff(). Để đánh giá một đạo hàm chưa được đánh giá, hãy sử dụng phương thức doit()

cú pháp. Đạo hàm (biểu thức, biến tham chiếu)

Thông số.
expression – Một biểu thức SymPy có đạo hàm chưa đánh giá được tìm thấy.
biến tham chiếu – Biến đối với đạo hàm được tìm thấy.

trả lại. Trả về một đạo hàm chưa đánh giá của biểu thức đã cho

Ví dụ 1




Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
2

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
3
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
4
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
5
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
7

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
8
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
9
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
0
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
1
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
2

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
3
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
9
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
5_______26
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
8
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
9
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
8
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
22
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
9
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
22
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
27

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
28
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
29____230
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
31
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
32
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
33

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
34

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
35

________ 236 ________ 29 ________ 238

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
39

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
28
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
29____242
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
31
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
32
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
45

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
28
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
29____248
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
31
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
32
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
51

đầu ra

Expression : x**2 + y**3 + 2*y 
Derivative of expression with respect to x : Derivative(x**2 + y**3 + 2*y, x)
Value of the derivative : 2*x 

Ví dụ #2




Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
2

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
3
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
4
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
5
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
7

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
8
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
9
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
0
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
1
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
2

Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
3_______29
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
22
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
8
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
5_______26
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
8
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
9
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
8
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
22
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
5
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
9
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
5
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
27
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
22
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
6
Expression : x**3*y**3 + x**2*y**2 + 2*x*y 
Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y)
Value of the derivative : 9*x**2*y**2 + 4*x*y + 2 
27