These questions are so classic that they appear so many times that it's worth it to dedicate a Hall of Fame for them.

# Classic Problem 1

## Control the Temperature - How much wood is needed?

This question basically utilizes the bisection method.

This is a collection, don't run it, because some variables are not defined.


```python
import numpy as np

offset = 375
intervals = [(0, max_wood)]

while abs(get_temperature((intervals[-1][0] + intervals[-1][1]) / 2) - 375) >= epsilon:
    mid = (intervals[-1][0] + intervals[-1][1]) / 2
    if get_temperature(mid) - 375 > 0:
        intervals.append((intervals[-1][0], mid))
    else:
        intervals.append((mid, intervals[-1][1]))
        
weight = (intervals[-1][0] + intervals[-1][1]) / 2
```

# Interesting Problem 1

## Sparse Matrix-vector multiplication

This question only appeared once, but I think it's fun.


```python
import numpy as np

Ax = np.zeros(shape[0])

indexes = list(A)
for i in range(len(indexes)):
    for k in A[indexes[i]]:
        Ax[indexes[i]] += A[indexes[i]][k] * x[k]
```

# Classic Problem 2

## Estimate the amount of clay

This question utilizes the Monte Carlo Method, fun to work on.

Nevertheless, remember to read the conditions carefully so that you don't miss any of them.


```python
import numpy as np
from random import random

n = 100000
count = 0

for i in range(n):
    x = random()*10-5
    y = random()*10-5
    z = random()*2
    if z < f(x, y) and x**2+y**2 < 25:
        count += 1
        
volume = count / n * 10 * 10 * 2
```

# Classic Problem 3

## Solve linear system using SVD

So this question basically only allows you to multiply $U$ on the right and $V$ on the left. We will assume that A is invertible, which saves a lot of troubles.

Let's try to justify it with analytic expression:

$Ax=b$

$A^{-1}Ax = A^{-1}b$

$x = V\Sigma^{-1}U^Tb$

$x = V\Sigma^{-1}(b^TU)^T$

Therefore, we can conclude that the following code works:


```python
import numpy as np
x = left_multiply_with_V(np.diag(1/sigma)@right_multiply_with_U(b).T)
```

# Interesting Problem 2

## Newton's Method - Newton's Method

This is Newton's method used for ND solve. At first I think my scripts are not directly applicable, but then I found a way to transform the problem into what I need.


```python
import numpy as np
import numpy.linalg as la
import sympy as sp

# These functions are from the newton_nd_solve script
def subs_all…
def calculated_jacobian…
def newton_nd_step…

f_strs = ['16*x**4+16*y**4+z**4-16', 'x**2+y**2+z**2-3', 'x**3-y']
x_prev = [1, 1, 1]
var_str = 'x y z'
res = []
for i in range(5):
    x_prev = [1, 1, 1]
    for j in range(i+1):
        jac, x_prev = newton_nd_step(x_prev, f_strs, var_str)
    res.append(np.array(x_prev))
guesses = np.array(res)
```

da142070dd056e9e4905ab501200b4b7b65ecb48
ipynb
Jupyter Notebook
hall_of_fame.ipynb
Racso-3141/uiuc-cs357-fa21-scripts
e44f0a1ea4eb657cb77253f1db464d52961bbe5e
MIT
2021-11-02T05:56:10.000Z
2022-03-03T19:25:19.000Z
hall_of_fame.ipynb
Racso-3141/uiuc-cs357-fa21-scripts
e44f0a1ea4eb657cb77253f1db464d52961bbe5e
MIT
hall_of_fame.ipynb
Racso-3141/uiuc-cs357-fa21-scripts
e44f0a1ea4eb657cb77253f1db464d52961bbe5e
MIT
2021-10-30T15:18:01.000Z
2021-12-10T11:26:43.000Z
Qwen/Qwen-72B
1. YES
2. YES