Help us understand the problem. What is going on with this article?

# GCIデータサイエンティスト育成講座の解答を作ってみた(5章)

More than 1 year has passed since last update.

5.3.1 Scipy

<練習問題 1>

<練習問題 2>

```x = np.linspace(0, 10, num=11, endpoint=True)
y = np.sin(x**2/5.0)
plt.plot(x,y,'o')
plt.grid(True)
x1 = np.linspace(0, 10, num=100, endpoint=True)
f=interpolate.interp1d(x, y,'linear')
f2=interpolate.interp1d(x, y,'cubic')
plt.plot(x1,f(x1),"-",x1,f2(x1),"--")
```

<練習問題 1>

B = np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,12]])

```B = np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,12]])
U, s, Vs = sp.linalg.svd(B)
m, n = B.shape
S = sp.linalg.diagsvd(s,m,n)
print("U.S.V* = \n\n",U@S@Vs)
```

<練習問題 2>

```#データの準備
A = np.identity(3)
print(A)
A[0,:] = 1
A[:,0] = 1
A[0,0] = 3
b = np.ones(3)
(LU,piv) = sp.linalg.lu_factor(A)
L = np.identity(3) + np.tril(LU,-1)
U = np.triu(LU)
P = np.identity(3)[piv]
# 解を求める
x = sp.linalg.lu_solve((LU,piv),b)
```

<練習問題 1>

```integrate.quad(lambda x:(x+1)**2,0,2)
```

<練習問題 2>
cos関数の範囲 (0,𝜋) の積分を求めてみましょう。

```from numpy import cos
```

<練習問題 1>

```def f(x):
return 5*x-10
sol1=fsolve(f,0)
print(sol1)

```

<練習問題 2>

```def f2(x):
return x**3-2*x**2-11*x+12
sol2=fsolve(f2,0)
print(sol2)
```

5.4 総合問題
5.4.1 総合問題1

```A = np.array([[5, 1, 0, 1],
[1, 9, -5, 7],
[0, -5, 8, -3],
[1, 7, -3, 10]])
b = np.array([2, 10, 5, 10])

L = sp.linalg.cholesky(A)

t = sp.linalg.solve(L.T.conj(), b)
x = sp.linalg.solve(L, t)
```
```# 解答
print(x)
[-0.051  2.157  2.01   0.098]
```

5.4.3 総合問題3

```

Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away