1. Trang chủ
  2. » Luận Văn - Báo Cáo

Thảo luận nhóm TMU bản báo cáo TỔNG hợp học PHẦN TOÁN CAO cấp 2 nhiệm vụ sử dụng python để giải các bài toán

53 5 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Sử Dụng Python Để Giải Các Bài Toán
Tác giả Lê Thị Giang, Đinh Thùy Dương, Nguyễn Hưng Duy, Nguyễn Thị Hương Giang, Nguyễn Thu Hà, Trần Thị Hà, Nguyễn Thị Hằng, Nguyễn Thị Thúy Hằng, Nguyễn Thúy Hằng, Trần Thị Thu Hiền
Người hướng dẫn Lê Văn Tuấn
Trường học Trường Đại Học Thương Mại
Chuyên ngành Hệ Thống Thông Tin Kinh Tế & Thương Mại Điện Tử
Thể loại báo cáo
Năm xuất bản 2021
Thành phố Hà Nội
Định dạng
Số trang 53
Dung lượng 1,77 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

KHOA HỆ THỐNG THÔNG TIN KINH TẾ & THƯƠNG MẠI ĐIỆN TỬBẢN BÁO CÁO TỔNG HỢP HỌC PHẦN TOÁN CAO CẤP 2 Nhiệm vụ: “Sử dụng Python để giải các bài toán”... e −x 2 import math import numpy as np

Trang 1

KHOA HỆ THỐNG THÔNG TIN KINH TẾ & THƯƠNG MẠI ĐIỆN TỬ

BẢN BÁO CÁO TỔNG HỢP

HỌC PHẦN TOÁN CAO CẤP 2

Nhiệm vụ: “Sử dụng Python để giải các bài toán”.

Lớp học phần: 2192FMAT0211 Nhóm thực hiện: 03

Giảng viên giảng dạy: Lê Văn Tuấn

Trang 2

Nhóm trưởng: Lê Thị Giang

ST

Hà Nội, ngày 5/10/2021 Nhóm trưởng

Lê Thị Giang

Trang 3

NV2 Tính các tích phân trong bài 8.1 với cận 3 đến 12.

NV3 Vẽ đồ thị nghiệm riêng của các PTVP trong bài 9.4 với điều kiện ban đầu y(3) = 2

Trang 4

1 z = x 3 + y 3

x 2 − y 2

import numpy as np

from sympy import *

x, y = symbols ('x y', real=True)

import numpy as np

from sympy import *

x, y = symbols ('x y', real=True)

from sympy import *

x, y = symbols ('x y', real=True)

Trang 5

x, y = symbols('x y', real=True)

z = (x**3 + y**3) / (x**2 + y**2) z_x = diff(z, x)

z_xy = (diff(z_x,y)) z_xy = lambdify((x, y), z_xy) print(z_xy(3,12))

0.002713888323495478

z ' ' xy (3,12 ) = z ' yx (3,12)

= 0.002713888323495478

import numpy as np from sympy import *

x, y = symbols('x y', real=True)

z = (x**3 + y**3) / (x**2 + y**2) z_y = diff(z, y)

z_yy = (diff(z_y,y)) z_yy = lambdify((x, y), z_yy) print(z_yy(3,12))

x, y = symbols ('x y', real=True)

z = log(x+sqrt(x**2 + y**2)) z_x = diff (z, x)

z_x = lambdify ((x, y), z_x) print (z_x(3,12))

Màn hình hiển thị:

0.08084520834544434

z ' x ( 3,12) = √ 153 1 = 0.08084520834544434

import numpy as np from sympy import *

x, y = symbols ('x y', real=True)

z = log(x+sqrt(x**2 + y**2)) z_y = diff (z, y)

z_y = lambdify ((x, y), z_y)

Trang 6

import numpy as np from sympy import *

x, y = symbols ('x y', real=True)

z = log(x+sqrt(x**2 + y**2)) z_x = diff(z, x)

z_xx = (diff(z_x,x)) z_xx = lambdify((x, y), z_xx) print(z_xx(3,12))

Màn hình hiển thị:

- 0.0015852001636361647

z ' ' xx (3,12 ) = - 0.0015852001636361647

import numpy as np from sympy import *

x, y = symbols('x y', real=True)

z = log(x+sqrt(x**2 + y**2)) z_x = diff(z, x)

z_xy = (diff(z_x,y)) z_xy = lambdify((x, y), z_xy) print(z_xy(3,12))

x, y = symbols('x y', real=True)

z = log(x+sqrt(x**2 + y**2)) z_y = diff(z, y)

z_yy = (diff(z_y,y)) z_yy = lambdify((x, y), z_yy) print(z_yy(3,12))

x, y = symbols ('x y', real=True)

z = exp(atan(y/x)) z_x = diff (z, x)

Màn hình hiển thị:

- 0.295314730609362

z ' x ( 3,12) = −12

153 e arctan 4

Trang 7

z_x = lambdify ((x, y), z_x) print (z_x(3,12)

= - 0.295314730609362

import numpy as np from sympy import *

x, y = symbols ('x y', real=True)

z = exp(atan(y/x)) z_y = diff (z, y) z_y = lambdify ((x, y), z_y) print (z_y(3,12))

x, y = symbols ('x y', real=True)

z = exp(atan(y/x)) z_x = diff(z, x) z_xx = (diff(z_x,x)) z_xx = lambdify((x, y), z_xx) print(z_xx(3,12))

Màn hình hiển thị:

0.034742909483454376

z ' ' xx (3,12 ) = 0.034742909483454376

import numpy as np from sympy import *

x, y = symbols('x y', real=True)

z = exp(atan(y/x)) z_x = diff(z, x) z_xy = (diff(z_x,y)) z_xy = lambdify((x, y), z_xy) print(z_xy(3,12))

x, y = symbols('x y', real=True)

Màn hình hiển thị:

- 0.010133348599340853

Trang 8

z_y = diff(z, y) z_yy = (diff(z_y,y)) z_yy = lambdify((x, y), z_yy) print(z_yy(3,12))

x, y = symbols ('x y', real=True)

z = log (((sqrt(x**2 + y**2))-x) / ((sqrt(x**2 + y**2))+x))

z_x = diff (z, x) z_x = lambdify ((x, y), z_x) print (z_x(3,12))

x, y = symbols ('x y', real=True)

z = log (((sqrt(x**2 + y**2))-x) / ((sqrt(x**2 + y**2))+x))

z_y = diff (z, y) z_y = lambdify ((x, y), z_y) print (z_y(3,12))

x, y = symbols ('x y', real=True)

z = log (((sqrt(x**2 + y**2))-x) / ((sqrt(x**2 + y**2))+x))

z_x = diff(z, x) z_xx = (diff(z_x,x))

Màn hình hiển thị:

0.003170400327272324

z ' ' xx (3,12 ) = 0.003170400327272324

Trang 9

z_xx = lambdify((x, y), z_xx) print(z_xx(3,12))

import numpy as np from sympy import *

x, y = symbols('x y', real=True)

z = log (((sqrt(x**2 + y**2))-x) / ((sqrt(x**2 + y**2))+x))

z_x = diff(z, x) z_xy = (diff(z_x,y)) z_xy = lambdify((x, y), z_xy) print(z_xy(3,12))

x, y = symbols('x y', real=True)

z = log (((sqrt(x**2 + y**2))-x) / ((sqrt(x**2 + y**2))+x))

z_y = diff(z, y) z_yy = (diff(z_y,y)) z_yy = lambdify((x, y), z_yy) print(z_yy(3,12))

x, y = symbols ('x y', real=True) z= pow(x,(y**3))

z_x = diff (z, x) z_x = lambdify ((x, y), z_x) print (z_x(3,12))

Màn hình hiển thị:

OverflowError: integer division result too large for a float.

z ' x ( 3,12) = 3 1727 12 3

Trang 10

from sympy import *

x, y = symbols ('x y', real=True) z= pow(x,(y**3))

z_y = diff (z, y) z_y = lambdify ((x, y), z_y) print (z_y(3,12))

OverflowError: integer division result too large for a float

z ' y( 3,12) = 3 12

3

3.12 2 ln 3

import numpy as np from sympy import *

x, y = symbols ('x y', real=True)

z = pow(x,(y**3)) z_x = diff(z, x) z_xx = (diff(z_x,x)) z_xx = lambdify((x, y), z_xx) print(z_xx(3,12))

x, y = symbols('x y', real=True)

z = pow(x,(y**3)) z_x = diff(z, x) z_xy = (diff(z_x,y)) z_xy = lambdify((x, y), z_xy) print(z_xy(3,12))

x, y = symbols('x y', real=True)

z = pow(x,(y**3)) z_y = diff(z, y) z_yy = (diff(z_y,y)) z_yy = lambdify((x, y), z_yy)

Màn hình hiển thị:

OverflowError: int too large to convert to float

z ' ' yy(3,12 ) =

Trang 11

x, y = symbols ('x y', real=True) z= atan(sqrt(x**2-y**2)/sqrt(x**2+y**2)) z_x = diff (z, x)

z_x = lambdify ((x, y), z_x) print (z_x(3,12))

x, y = symbols ('x y', real=True) z= atan(sqrt(x**2-y**2)/sqrt(x**2+y**2)) z_y = diff (z, y)

z_y = lambdify ((x, y), z_y) print (z_y(3,12))

x, y = symbols ('x y', real=True) z= atan(sqrt(x**2-y**2)/sqrt(x**2+y**2)) z_x = diff(z, x)

z_xx = (diff(z_x,x)) z_xx = lambdify((x, y), z_xx) print(z_xx(3,12))

Màn hình hiển thị:

z ' ' xx (3,12 ) =

import numpy as np from sympy import *

x, y = symbols('x y', real=True) z= atan(sqrt(x**2-y**2)/sqrt(x**2+y**2)) z_x = diff(z, x)

z_xy = (diff(z_x,y)) z_xy = lambdify((x, y), z_xy)

Màn hình hiển thị:

z ' ' xy (3,12 ) = z ' yx (3,12)

=

Trang 12

import numpy as np from sympy import *

x, y = symbols('x y', real=True) z= atan(sqrt(x**2-y**2)/sqrt(x**2+y**2)) z_y = diff(z, y)

z_yy = (diff(z_y,y)) z_yy = lambdify((x, y), z_yy) print(z_yy(3,12))

x, y = symbols ('x y', real=True) z= (x+y)**(sin(x)*sin(y)) z_x = diff (z, x)

z_x = lambdify ((x, y), z_x) print (z_x(3,12))

x, y = symbols ('x y', real=True) z= (x+y)**(sin(x)*sin(y)) z_y = diff (z, y)

z_y = lambdify ((x, y), z_y) print (z_y(3,12))

x, y = symbols ('x y', real=True)

z = (x+y)**(sin(x)*sin(y)) z_x = diff(z, x)

z_xx = (diff(z_x,x)) z_xx = lambdify((x, y), z_xx) print(z_xx(3,12))

Trang 13

from sympy import *

x, y = symbols('x y', real=True)

z = (x+y)**(sin(x)*sin(y)) z_x = diff(z, x)

z_xy = (diff(z_x,y)) z_xy = lambdify((x, y), z_xy) print(z_xy(3,12))

-1.4366296429295926

z ' xy ( 3,12) = z ' yx (3,12) =

import numpy as np from sympy import *

x, y = symbols('x y', real=True)

z = (x+y)**(sin(x)*sin(y)) z_y = diff(z, y)

z_yy = (diff(z_y,y)) z_yy = lambdify((x, y), z_yy) print(z_yy(3,12))

f = lambda x: x/math.sqrt(x**4-1) result = integrate.quad(f, 3, 12) print(result)

Màn hình hiện kết quả là:

1.3878387366165639, 9.369492060784994e-10

Trang 14

from scipy import integrate

f = lambda x: math.sqrt(3*x+5) / x result = integrate.quad(f, 3, 12) print(result)

6.7758332587582695, 1.1351502655320377e-10

12

¿

import math from scipy import integrate

f = lambda x: (1+x-x**2) / math.sqrt((1-x**2)**3) result = integrate.quad(f, 3, 12) print(result)

f = lambda x: math.sin(4*x) / ((math.cos(2*x))**2+4) result = integrate.quad(f, 3, 12) print(result)

Màn hình hiện kết quả là:

0.0817030676982187, 2.80697913538785e-10

Giá trị tích phân là:

0.0817030676982187

Trang 15

5. ∫ 3

f = lambda x: (1+(math.sqrt(x))**(1/2)) / (1+math.sqrt(x))

result = integrate.quad(f, 3, 12) print(result)

Màn hình hiện kết quả là:

6.4856945240125405, 1.3972082175248163e-13

f = lambda x: (x**(1/6))/(1+x**(1/3)) result = integrate.quad(f, 3, 12) print(result)

Màn hình hiện kết quả là:

4.265982948939681, 9.520275988605531e-14

f = lambda x: x**2)

x**3*math.sqrt(4-result = integrate.quad(f, 3, 12) print(result)

Trang 16

8. ∫ 3

12 1

x −x 2 dx

import math from scipy import integrate

f = lambda x: x**2)

1/math.sqrt(x-result = integrate.quad(f, 3, 12) print(result)x**3*math.sqrt(4- x**2)

f = lambda x: math.sqrt((x -1)/

(x+1))*(1/x**2) result = integrate.quad(f, 3, 12) print(result)

Màn hình hiện kết quả là:

0.20269413583378698, 2.601449608051369e-10

f = lambda x: math.log(math.tan(x)) / (math.sin(x)*math.cos(x)))

result = integrate.quad(f, 3, 12) print(result)

Trang 18

NHIỆM VỤ 3: Vẽ đồ thị nghiệm riêng của các PTVP trong bài 9.4 với điều kiện ban đầu y(3) = 2 trên miền [3, 12].

1 +x 2 y

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

def model(y,x):

dydx = (2*x/(1+x**2))*y return dydx

y3 = 2

x = np.linspace(3,12)

y = odeint(model,y3,x) plt.plot(x,y)

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

2 y ' + =4 x y

import math

Trang 19

import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

def model(y,x):

dydx = 4*x - y return dydx y3 = 2

x = np.linspace(3,12)

y = odeint(model,y3,x) plt.plot(x,y)

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

3 y ' +2 xy=x e −x 2

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

def model(y,x):

Trang 20

return dydx y3 = 2

x = np.linspace(3,12)

y = odeint(model,y3,x) plt.plot(x,y)

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

4 y ' − ysinx=sinx cosx

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 21

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

5. y ' + xy

1−x 2 =arcsinx x +

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

Trang 22

6. y ' =2 x( x 2

+ y )

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

def model(y,x):

dydx = 2*x*(x**2+y) return dydx

y3 = 2

x = np.linspace(3,12)

y = odeint(model,y3,x) plt.plot(x,y)

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

7. xy '

−2 y =2 x 4

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 23

def model(y,x):

dydx = (2*x**4 + 2*y)/x return dydx

y3 = 2

x = np.linspace(3,12)

y = odeint(model,y3,x) plt.plot(x,y)

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

8. y ' √ 1−x 2

+ y=arcsin x

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

def model(y,x):

dydx = (math.asin(x) - y)/math.sqrt(1 - x**2) return dydx

y3 = 2

Trang 24

y = odeint(model,y3,x) plt.plot(x,y)

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

ValueError: math domain error - lỗi vì tập xác định của arcsin(x) là x € (-1;1)

9 y 'y

x lnx =xlnx

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

Trang 26

NHIỆM VỤ 4: Vẽ đồ thị nghiệm riêng của các PTVP trong bài 9.7 với điều kiện y(3)

= 2, y’(3) = 1 trên miền [3, 12].

1 y ' ' −2 y '

− y=0

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

2 y ' ' y e

−9 '

= 3 x cos x

import math

Trang 27

import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

3 4 y ' '

−20 y ' + 25 y = 0

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 28

def model(U, x):

return [U[1], 4*U[1] - 12*x**2 - 6*x - 4]

U0 = [2, 1]

xs = np.linspace(3, 12)

Trang 29

Us = odeint(model, U0, xs)

ys = Us[:,0]

plt.xlabel("Truc x") plt.ylabel("Truc y") plt.title("PTVP") plt.plot(xs,ys) plt.show()

5 y ' ' y y e

−2 '

−3 = 4 x

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 30

plt.title("PTVP") plt.plot(xs,ys) plt.show()

6 y ' ' −5 y ' +4 =4 x y 2 e x

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 31

7 y ' '

− y =2 sin −4 cos x x

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 32

8 y ' ' −4 y ' e

= x [(−4 x +4) cos x−(2 x +6 )sin x ]

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 33

9 y ' ' + =cos +cos 2 x y x

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 34

10 y ' ' y x

− =2 e x

− 2

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 36

NHIỆM VỤ 5: Vẽ đồ thị nghiệm riêng của các PTSP trong bài 10.4 với điều kiện ban đầu x(0) = 3 trên miền [0, 9].

import math import numpy as np import matplotlib.pyplot as plt

N = 9

x = np.zeros(N, int) x[0] = 3

for n in range(1, N):

x[n] = n*x[n-1]+math.factorial(n) plt.plot(x)

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

Trang 37

import math import numpy as np import matplotlib.pyplot as plt

N = 9

x = np.zeros(N, int) x[0] = 3

for n in range(1, N):

x[n] = math.factorial(n-1)-(n-1)*x[n-1]

plt.plot(x) plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

2

+2 n

import math import numpy as np import matplotlib.pyplot as plt

Trang 38

N = 9

x = np.zeros(N, float) x[0] = 3

for n in range(1, N):

x[n] = math.pow(9,n-1)*x[n-1]+math.pow(3,(n-1)**2+2*(n-1)) plt.plot(x)

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

3 n

import math import numpy as np import matplotlib.pyplot as plt

N = 9

x = np.zeros(N, int) x[0] = 3

Trang 39

for n in range(1, N):

x[n] = math.factorial(n-1)/math.pow(3,n-1)-(n-1)/3*x[n-1] plt.plot(x)

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

2 n +1

import math import numpy as np import matplotlib.pyplot as plt

N = 9

x = np.zeros(N, int) x[0] = 3

for n in range(1, N):

x[n] =(n-1)/2*x[n-1]+math.factorial(n-1)/math.pow(2,n) plt.plot(x)

Trang 40

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

import math import numpy as np import matplotlib.pyplot as plt

N = 9

x = np.zeros(N, int) x[0] = 3

for n in range(1, N):

x[n] = math.pow(4,-(n-1))*x[n-1]+(n-1)*math.pow(2,-(n-1)**2-(n-1)) plt.plot(x)

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

Trang 41

plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()

Trang 44

NHIỆM VỤ 4: Vẽ đồ thị nghiệm riêng của các PTVP trong bài 9.7 với điều kiện y(3)

= 2, y’(3) = 1 trên miền [3, 12].

1 y ' ' y

−2 '

− y=0

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 45

import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 46

xs = np.linspace(3, 12)

Us = odeint(model, U0, xs)

ys = Us[:,0]

plt.xlabel("Truc x") plt.ylabel("Truc y") plt.title("PTVP") plt.plot(xs,ys) plt.show()

3 4 y ' ' −20 y ' + 25 y = 0

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 48

4 y ' ' −4 y '

=−12 x 2

−6 x−4

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

def model(U, x):

return [U[1], 4*U[1] - 12*x**2 - 6*x - 4] U0 = [2, 1]

xs = np.linspace(3, 12)

Trang 49

Us = odeint(model, U0, xs)

ys = Us[:,0]

plt.xlabel("Truc x") plt.ylabel("Truc y") plt.title("PTVP") plt.plot(xs,ys) plt.show()

5 y ' ' −2 y ' y e

−3 = 4 x

import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt

Trang 50

xs = np.linspace(3, 12)

Us = odeint(model, U0, xs)

ys = Us[:,0]

plt.xlabel("Truc x") plt.ylabel("Truc y")

Ngày đăng: 23/12/2023, 18:03

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w