_Latihan soal ini dari perkuliahan Analisis Sumber Daya Air (SI-6232) tahun 2018 Semester Genap diajarkan oleh Dr. Dhemi Harlan ST, MT, MSc._

# Metoda Calculus



## Calculus Single Variable


```python
from sympy import symbols, latex, simplify, init_printing, solve, solveset, Eq
from sympy import Rational as rat
init_printing()

sx = symbols('x')

fx = (1/4)*sx**4 - (1/2)*sx**2
fxd = fx.diff(sx)
fxdd = fx.diff(sx,sx)

def f(x):
    return float(fx.subs({sx: x}))

def fd(x):
    return float(fxd.subs({sx: x}))

def fdd(x):
    return float(fxdd.subs({sx: x}))
```


```python
import numpy as np
import matplotlib.pyplot as plt

axis = np.linspace(xa,xb,1000)
y, yd, ydd = [], [], []
for x in axis:
    y.append(f(x))
    yd.append(fd(x))
    ydd.append(fdd(x))

plt.rcParams["figure.figsize"] = (10, 12)
plt.plot(axis, y)
plt.plot(axis, yd)
plt.plot(axis, ydd)
plt.grid()

```


```python
result = solve(fxd,sx)

for x in result:
    print(fdd(x), '----', f(x))
```

    2.0 ---- -0.25
    -1.0 ---- 0.0
    2.0 ---- -0.25



```python
ex2f = sx**5
ex2fd = ex2f.diff(sx)
ex2fdd = ex2f.diff(sx, sx)
ex2fddd = ex2f.diff(sx, sx, sx)
ex2fdddd = ex2f.diff(sx, sx, sx, sx)
```


```python
ex3f = 12*sx**5 - 45*sx**4 + 40*sx**3 + 5
ex3f.diff(sx)
```


```python
hasil = solve(ex3f.diff(sx),sx)
print(hasil)
for x in hasil:
    print(ex3f.diff(sx,sx).subs({sx: x}))
```

    [0, 1, 2]
    0
    -60
    240



```python
ex3f.diff(sx, sx, sx).subs({sx: 0})
```


```python
from sympy import factor
factor(ex3f.diff(sx, sx, sx))
```


```python
ex3f.diff(sx, sx, sx).subs({sx: 0})
```


```python

```

513a714a2743303c57cb9a1a5033ece011ea6e4f
ipynb
Jupyter Notebook
ansis/Calculus/Metoda Calculus.ipynb
taruma/belajar-tsa
ded702846f0453993ba90738a4b6b2401abe9177
MIT
ansis/Calculus/Metoda Calculus.ipynb
taruma/belajar-tsa
ded702846f0453993ba90738a4b6b2401abe9177
MIT
ansis/Calculus/Metoda Calculus.ipynb
taruma/belajar-tsa
ded702846f0453993ba90738a4b6b2401abe9177
MIT
Qwen/Qwen-72B
1. YES
2. YES