```python
# https://www.khanacademy.org/math/ap-calculus-ab/ab-diff-analytical-applications-new/ab-5-11/v/minimizing-the-cost-of-a-storage-container
from IPython.display import Image
from IPython.core.display import HTML 
from sympy import *; x,h,y,n,t,d,c   = symbols("x h y n t d c"); C, D = symbols("C D", real=True)
Image(url= "https://i.imgur.com/iU00Tki.png")
```









```python
cost_of_base = 10*x*(2*x)
cb = cost_of_base
cb
```




$\displaystyle 20 x^{2}$




```python
cost_of_side_pair0 = 2*5*x*h 
cs0 = cost_of_side_pair0
cs0
```




$\displaystyle 10 h x$




```python
cost_of_side_pair1 = 2*5*2*x*h
cs1 = cost_of_side_pair1
cs1
```




$\displaystyle 20 h x$




```python
total_cost = cb + cs0 + cs1
tc = total_cost
tc
```




$\displaystyle 30 h x + 20 x^{2}$




```python
# now lets optimize this in respect to x
```


```python
Eq(x*2*x*h,16)
```




$\displaystyle 2 h x^{2} = 16$




```python
# to make Eq(x*2*x*h,16) a function of h(x) then solve for h
solve(Eq(x*2*x*h,16),h)
```




    [8/x**2]




```python
8/x**2
```




$\displaystyle \frac{8}{x^{2}}$




```python
#let us substitute 8/x**2 for h in our variable tc
```


```python
tc
```




$\displaystyle 30 h x + 20 x^{2}$




```python
tc.subs(h, 8/x**2)  
```




$\displaystyle 20 x^{2} + \frac{240}{x}$




```python
def C(x):
    return tc.subs(h, 8/x**2)
C(x)
```




$\displaystyle 20 x^{2} + \frac{240}{x}$




```python
# now let us optomize C(x) and
# find the critical points to find min/max values
diff(C(x))  # find the derivative 

```




$\displaystyle 40 x - \frac{240}{x^{2}}$




```python
# find when diff(C(x)) is 0
Eq(diff(C(x)) ,0)
```




$\displaystyle 40 x - \frac{240}{x^{2}} = 0$




```python
solve(diff(C(x)) ,x)
```




    [6**(1/3),
     -6**(1/3)/2 - 2**(1/3)*3**(5/6)*I/2,
     -6**(1/3)/2 + 2**(1/3)*3**(5/6)*I/2]




```python
# 6**(1/3) is our critical point
critical_point = 6**(1/3)
cp = critical_point
cp
```




    1.8171205928321397




```python
simplify(diff(C(x),x,2)) #second derivative to see concave upward
```




$\displaystyle 40 + \frac{480}{x^{3}}$




```python
C(x).subs(x,cp)
```




$\displaystyle 198.115634933678$




```python
Image(url= "https://i.imgur.com/hLdDjpC.png")
```








5f70f74fc0b27ffaffd2caf79ef1a3c607fc02de
ipynb
Jupyter Notebook
Calculus_Homework/WWB14.3.ipynb
NSC9/Sample_of_Work
8f8160fbf0aa4fd514d4a5046668a194997aade6
MIT
Calculus_Homework/WWB14.3.ipynb
NSC9/Sample_of_Work
8f8160fbf0aa4fd514d4a5046668a194997aade6
MIT
Calculus_Homework/WWB14.3.ipynb
NSC9/Sample_of_Work
8f8160fbf0aa4fd514d4a5046668a194997aade6
MIT
Qwen/Qwen-72B
1. YES
2. YES