```python
from Integrais import Integrais as it
from EDO import EDO
from sympy import var, Lambda, cos, sin, tan, exp, log, ln, sqrt, solve
x = var('x')
y = var('y')
```


```python
# Questão 01
x0 = 0
y0 = 1
dy = Lambda((x, y), x*y**2 - y)
print('f(x, y) = ', dy(x,y))
I = (0, 2)
N = 8
Y = EDO(dy, y0, x0)
y1, y_steps, x_steps = Y.euler(I, N, dp=6)
print(f'Solução Aproximada: y(2) = {y1}')
```

    f(x, y) =  x*y**2 - y
    Solução Aproximada: y(2) = 0.22829



```python
# Questão 02
x0 = 0
y0 = 0
dy = Lambda((x, y), 2*x + y)
print('f(x, y) = ', dy(x,y))
I = (0, 0.6)
N = 3
Y = EDO(dy, y0, x0)
y1, y_steps, x_steps = Y.runge_kutta2(I, N, dp=7)
print(f'Solução Aproximada: y(0.6) = {y1}')
```

    f(x, y) =  2*x + y
    Solução Aproximada: y(0.6) = 0.431696



```python
# Questão 3
f = Lambda(x, sqrt(4 + x**2))
a = 0
b = 3
display(f)

Q1 = it(f, a, b)
Q1.simpson3_8(n=6)
```


$\displaystyle \left( x \mapsto \sqrt{x^{2} + 4} \right)$


    *************** Regra de 3/8 de Simpson ***************
    Portanto, o valor da integral é:
    7.7978, com |E| < 0.0009
    





    7.7978




```python
# Questão 4
f = Lambda(x, x**3 * exp(2*x))
a = 0
b = 2
display(f)

Q1 = it(f, a, b)
Q1.simpson1_3(n=8)
```


$\displaystyle \left( x \mapsto x^{3} e^{2 x} \right)$


    *************** Regra de 1/3 de Simpson ***************
    Portanto, o valor da integral é:
    116.7145, com |E| < 2.0095
    
    ********************  AVISO  ********************
    Para garantia de um |E| < 0.01, utilize n = 32.0
    





    116.7145



8d3515e9cc86f1a77465be54fe1f517ad5c596b8
ipynb
Jupyter Notebook
MAT 271/P3.ipynb
Hiago013/Ola-Mundo
87a34020a421bca535eacbfc4e9e4e1dd36f67be
MIT
MAT 271/P3.ipynb
Hiago013/Ola-Mundo
87a34020a421bca535eacbfc4e9e4e1dd36f67be
MIT
MAT 271/P3.ipynb
Hiago013/Ola-Mundo
87a34020a421bca535eacbfc4e9e4e1dd36f67be
MIT
Qwen/Qwen-72B
1. YES
2. YES