from sympy import *x, y = symbols 'x y', real=True from sympy import * x, y = symbols 'x y', real=True from sympy import * x, y = symbols'x y', real=True from sympy import * OverflowErro
Trang 1BÔ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC THƯƠNG MẠI 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
HÀ NỘI – 2021
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 2DANH SÁCH THÀNH VIÊN NHÓM 03 – LỚP HP: 2192FMAT0211
Nhóm trưởng: Lê Thị Giang
ST
T
21 Đinh Thùy Dương Làm nhiệm vụ 1 và kiểm tra các đáp án
23 Lê Thị Giang Làm nhiệm vụ 6 và tổng hợp đáp án
24 Nguyễn Thị Hương Giang Làm nhiệm vụ 2
28 Nguyễn Thị Thúy Hằng Làm nhiệm vụ 4
Hà Nội, ngày 5/10/2021Nhóm trưởng
Lê Thị Giang
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 3NHIỆM VỤ CỦA NHÓM
NHIỆM VỤ 1: Tính đạo hàm riêng cấp 1 & 2 của các hàm số trong bài 7.2 tại
(3, 12) 1
NHIỆM VỤ 2: Tính các tích phân trong bài 8.1 với cận 3 đến 12 12
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] 16
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] 24
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] 34
NHIỆM VỤ 6: Vẽ đồ thị nghiệm riêng của các PTSP trong bài 10.7 với điều kiện: x(0) = 3, x(1) = 4 trên miền [0, 9] 42
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 4from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
Trang 5from sympy import *
x, y = symbols('x y', real=True)
from sympy import *
x, y = symbols('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
z = log(x+sqrt(x**2 + y**2))
z_y = diff (z, y)
2
Trang 6TIEU LUAN MOI download : skknchat123@gmail.com
Trang 7z_y = lambdify ((x, y), z_y)
print("z ' y =",z_y(3,12))
import numpy as np z ' xx = 0.034742909483454376
from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols('x y', real=True)
from sympy import *
x, y = symbols('x y', real=True)
Trang 8x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols('x y', real=True)
Trang 9from sympy import *
x, y = symbols('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
5
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 10from sympy import *
x, y = symbols('x y', real=True)
from sympy import *
x, y = symbols('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
z ' xy = 0.012681601309089316
z ' yy = -0.006538950674999176
Đáp án:
OverflowError: integer division result too
large for a float
6
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 11from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols('x y', real=True)
from sympy import *
OverflowError: integer division result too
large for a float
OverflowError: integer division result too
large for a float
OverflowError: integer division result too
large for a float
OverflowError: integer division result too
large for a float
7
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 12x, y = symbols('x y', real=True)
√ x
Thực hiện:
import numpy as np
from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
RuntimeWarning:
invalid value encountered in sqrt
RuntimeWarning:
invalid value encountered in sqrt
Trang 13from sympy import *
x, y = symbols('x y', real=True)
from sympy import *
x, y = symbols('x y', real=True)
RuntimeWarning:
invalid value encountered in sqrt
7 z = (x+ y )sinx siny
from sympy import *
x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
Trang 14x, y = symbols ('x y', real=True)
from sympy import *
x, y = symbols('x y', real=True)
from sympy import *
x, y = symbols('x y', real=True)
Trang 15NHIỆM VỤ 2: Tính các tích phân trong bài 8.1 với cận 3 đến 12.
import math 1.3878387366165639, 9.369492060784994e-10
from scipy import integrate
import math 6.7758332587582695, 1.1351502655320377e-10
from scipy import integrate
import math ValueErmror: math domain error. Điều kiện bài
11
Trang 16TIEU LUAN MOI download : skknchat123@gmail.com
Trang 17TIEU LUAN MOI download : skknchat123@gmail.com
Trang 18from scipy import integrate 14
import math ValueError: math domain error. Điều kiện bài
import math ValueError: math domain error. Điều kiện bài
2 > 0
1print(result)x**3*math.sqrt(4-
Trang 19TIEU LUAN MOI download : skknchat123@gmail.com
from scipy import integrate
from scipy import integrate
f = lambda x: math.log(math.tan(x)) /(math.sin(x)*math.cos(x)))
Trang 20TIEU LUAN MOI download : skknchat123@gmail.com
Trang 21NHIỆ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].
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()
15
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 22x = np.linspace(3,12)
y = odeint(model,y3,x)plt.plot(x,y)
plt.xlabel('Truc x')plt.ylabel('Truc y')plt.show()
Trang 23from scipy.integrate import odeint
plt.xlabel('Truc x')plt.ylabel('Truc y')plt.show()
Trang 24x, y = symbols ('x y', real=True)
import numpy as np z ' xy = -1.4366296429295926 from sympy import *
x, y = symbols('x y', real=True)
z = (x+y)**(sin(x)*sin(y))
TIEU LUAN MOI download : skknchat123@gmail.com
z x = diff(z, x)
Trang 25z_xy = (diff(z_x,y))
z_xy = lambdify((x, y), z_xy)
print("z ' xy =", z_xy(3,12))
import numpy as np z ' yy = 0.26233322953654437 from sympy import *
x, y = symbols('x y', real=True)
Trang 26NHIỆM VỤ 2: Tính các tích phân trong bài 8.1 với cận 3 đến 12.
from scipy import integrate
from scipy import integrate
f = lambda x: math.sqrt(3*x+5) / x
result = integrate.quad(f, 3, 12)
TIEU LUAN MOI download : skknchat123@gmail.com
print(result)
Trang 2711
Trang 28TIEU LUAN MOI download : skknchat123@gmail.com
Trang 307. ∫x3√4−x2 dx
3
Trang 31TIEU LUAN MOI download : skknchat123@gmail.com
from scipy import integrate
from scipy import integrate
f = lambda x: math.log(math.tan(x)) /(math.sin(x)*math.cos(x)))
Trang 32result = integrate.quad(f, 3, 12)
Trang 3314
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 34NHIỆ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].
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()
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 35TIEU LUAN MOI download : skknchat123@gmail.com
Trang 36x = np.linspace(3,12)
y = odeint(model,y3,x) plt.plot(x,y)
plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()
Trang 37from scipy.integrate import odeint
Trang 38plt.plot(x,y) plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()
Trang 39dydx = math.sin(x)*math.cos(x) + math.sin(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()
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 41y3 = 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()
ValueError: math domain error - lỗi vì tập xác định của arcsin(x) là x € [-1;1]
y3 = 2
x = np.linspace(3,12)
y = odeint(model,y3,x) plt.plot(x,y)
plt.xlabel('Truc x') plt.ylabel('Truc y')
TIEU LUAN MOI download : skknchat123@gmail.com
plt.show()
Trang 42TIEU LUAN MOI download : skknchat123@gmail.com
Trang 43y3 = 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()
20
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 448. y ' √1−x 2 + y=arcsin x
TIEU LUAN MOI download : skknchat123@gmail.com
import math
Trang 45plt.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]
21
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 46x = np.linspace(3,12)
y = odeint(model,y3,x) plt.plot(x,y)
plt.xlabel('Truc x') plt.ylabel('Truc y') plt.show()
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 47TIEU LUAN MOI download : skknchat123@gmail.com
Trang 48NHIỆ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
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 492. y ' ' −9 y ' =e3 x cos x
import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 51import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt
TIEU LUAN MOI download : skknchat123@gmail.com
plt.show()
Trang 524. y ' ' −4 y ' =−12 x2−6 x−4
import math import numpy as np from scipy.integrate import odeint
25
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 53TIEU LUAN MOI download : skknchat123@gmail.com
5. y ' ' − 2 y ' −3 y =e4 x
Trang 54import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt
26
Trang 55return [U[1], 2*U[1] + 3*U[0] + math.exp(4*x)] U0 = [2, 1]
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()
6. y ' ' −5 y ' +4 y =4 x2 e x
import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt
Trang 56TIEU LUAN MOI download : skknchat123@gmail.com
Trang 577. y ' ' − y =2 sin x−4 cos x
import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt
Trang 58Us = odeint(model, U0, xs)
ys = Us[:,0]
plt.xlabel("Truc x") plt.ylabel("Truc y") plt.title("PTVP") plt.plot(xs,ys) plt.show()
8. y ' ' −4 y ' =e x [(−4 x +4 ) cos x−(2 x +6 )sin x ]
TIEU LUAN MOI download : skknchat123@gmail.com
import math