plt.xlabel'Truc x'plt.ylabel'Truc y'plt.showplt.xlabel'Truc x'plt.ylabel'Truc y'plt.show ValueError: math domain error - lỗi vì tập xác định của arcsinx là x € -1;1 TIEU LUAN MOI downloa
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
Trang 2DANH SÁCH THÀNH VIÊN NHÓM 03 – LỚP HP: 2192FMAT0211
Nhóm trưởng: Lê Thị Giang
ST
T
Hà Nội, ngày 5/10/2021Nhóm trưởng
Trang 3NHIỆM VỤ CỦA NHÓM
NV1 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).
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 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 5x, 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 6TIEU LUAN MOI download : skknchat123@gmail.com
import numpy as np
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 *
x, y = symbols ('x y', real=True)
Trang 7TIEU LUAN MOI download : skknchat123@gmail.com
z_x = lambdify ((x, y), z_x)
print (z_x(3,12)
import numpy as np
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 *
x, y = symbols('x y', real=True)
Trang 8TIEU LUAN MOI download : skknchat123@gmail.com
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 9TIEU LUAN MOI download : skknchat123@gmail.com
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)
from sympy import *
x, y = symbols('x y', real=True)
from sympy import *
x, y = symbols ('x y', real=True)
Trang 10TIEU LUAN MOI download : skknchat123@gmail.com
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 *
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)
OverflowError: integer division result toolarge for a float
z ' y(3,12) = 312
Trang 11TIEU LUAN MOI download : skknchat123@gmail.com
Trang 12from 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)
Trang 13import numpy as np Màn hình hiển thị:
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 *
x, y = symbols ('x y', real=True)
Trang 14from sympy import * -1.4366296429295926
x, y = symbols('x y', real=True)
x, y = symbols('x y', real=True)
Trang 15from 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
1−x2 > 0-1 < x < 1
Giá trị tích phân là:
0.0817030676982187
Trang 164−x2 > 0-2 < x < 2
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 17Màn hình hiện kết quả là: Điều kiện bài
Trang 180 0
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 19NHIỆ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()
import math
Trang 20x = np.linspace(3,12)
y = odeint(model,y3,x)plt.plot(x,y)
plt.xlabel('Truc x')plt.ylabel('Truc y')plt.show()
Trang 21return dydxy3 = 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()
Trang 22plt.xlabel('Truc x')plt.ylabel('Truc y')plt.show()
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)
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 23y3 = 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()
Trang 24def model(y,x):
dydx = (2*x**4 + 2*y)/xreturn 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()
Trang 25y = 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)
plt.xlabel('Truc x')plt.ylabel('Truc y')plt.show()
Trang 260 0
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 27NHIỆ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].
import mathimport numpy as npfrom scipy.integrate import odeintimport matplotlib.pyplot as plt
import math
Trang 28import numpy as npfrom scipy.integrate import odeintimport matplotlib.pyplot as plt
import mathimport numpy as npfrom scipy.integrate import odeintimport matplotlib.pyplot as plt
0 0
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 29import mathimport numpy as npfrom scipy.integrate import odeintimport 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 30Us = odeint(model, U0, xs)
ys = Us[:,0]
plt.xlabel("Truc x")plt.ylabel("Truc y")plt.title("PTVP")plt.plot(xs,ys)plt.show()
import mathimport numpy as npfrom scipy.integrate import odeintimport matplotlib.pyplot as plt
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 31import mathimport numpy as npfrom scipy.integrate import odeintimport matplotlib.pyplot as plt
Trang 327. y ' ' − y =2 sin x−4 cos x
import mathimport numpy as npfrom scipy.integrate import odeintimport matplotlib.pyplot as plt
0 0
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 338. y ' ' −4 y ' =e x [(−4 x +4 ) cos x−(2 x +6 )sin x ]
import mathimport numpy as npfrom scipy.integrate import odeintimport matplotlib.pyplot as plt
Trang 349. y ' ' + y =cos x+cos 2 x
import mathimport numpy as npfrom scipy.integrate import odeintimport matplotlib.pyplot as plt
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 3510. y ' ' − y =2 e x −x2
import mathimport numpy as npfrom scipy.integrate import odeintimport matplotlib.pyplot as plt
Trang 360 0
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 37NHIỆ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].
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()
2 x(n+1) + nx(n) = n !
Trang 38for 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()
3 x(n+1) – 9n x(n) = 3n2 +
2 n import mathimport numpy as np
import matplotlib.pyplot as plt
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 39N = 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()
Trang 40for 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()
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)
0 0
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 41plt.xlabel('Truc x')plt.ylabel('Truc y')plt.show()
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 42def model(y,x):
dydx = x*math.log(x) + y/(x*math.log(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()
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 45NHIỆ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].
import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt
Trang 46import math
import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt
def model(U, x):
TIEU LUAN returnMOI[U[1],download9*U[0]+ math:skknchat123@gmail.exp(3*x)*math.cos(x)].com
Trang 47import math import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
Trang 48TIEU LUAN MOI download : skknchat123@gmail.com
Trang 494. 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 50Us = odeint(model, U0, xs)
ys = Us[:,0]
plt.xlabel("Truc x") plt.ylabel("Truc y") plt.title("PTVP") plt.plot(xs,ys) plt.show()
import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt
def model(U, x):
TIEU LUAN MOI download : skknchat123@gmail.com
return [U[1], 2*U[1] + 3*U[0] + math.exp(4*x)]
Trang 52plt.plot(xs,ys) plt.show()
import math import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt
TIEU LUAN MOI download : skknchat123@gmail.com
Trang 54import mathimport numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt
TIEU LUAN MOI download : skknchat123@gmail.com