W13 作业

10.1
import numpy as np
m = 20
n = 10
a = np.random.randn(m,n)
b = np.random.randn(m)
x = np.linalg.lstsq(a,b) 
print(x)

10.2

import numpy as np
from scipy import optimize as op
def f(x):
	return np.multiply(np.power(np.sin(x-2),2),np.exp(-np.power(x,2)))*(-1)
res = op.minimize_scalar(f)
print(-1*res.fun)

你可能感兴趣的:(作业,作业)