You are on page 1of 20

INTERPOLAÇÃO

15/05/2023
Pag. 152

t(h) T (o c)
6 24
7 25
8 27
9 28
10 30
11 30,5
12 31

(      
a0 + a1 · x0 = y0 1 x0 a y
=⇒ · 0 = 0
a0 + a1 · x1 = y1 1 x1 a1 y1

Exemplos
Qual a temperatura às 7:30hs
y = a0 + a1 x
(
a0 + 7a1 = 25 (−1)
a0 + 8a1 = 27 +
a1 = 2 =⇒ a0 = 11

1
1 interpolação continuação

Pag.: 167
data 19/05/2023

Interpolador de Lagrange
Os polinômios interpoladores de Lagrange, formam uma classe especifica de polinômios
que podem ser usados para fazer a interpolação de um determinado conjunto de dados,
simplesmente a partir dos valores dos pontos. A partir dos valores dos pontos. os po-
linômios podem ser escritos diretamente, e os coeficientes são determinados sem a neces-
sidade de nenhum cálculo preliminar.
A forma geral do polinômio interpolador de Lagrange é dada por:
n
Y
n
X (x − xj )
Pn (x) = yi
i=o
j=0 xi − x j
j ̸= i

demonstração:

Exemplo 1
pag: 167

Determinar:
• o polinômio interpolador de Lagrange para a função conhecida pelos pontos tabela-
dos abaixo

xi y1
0,0 0,000
0,2 2,008
0,4 4,064
0,5 5,125

3
3
Y
X (x − xj )
P3 (x) = yi =
i=o
j=0 xi − xj
j ̸= i

(x − x1 ) · (x − x2 ) · (x − x3 ) (x − x0 ) · (x − x2 ) · (x − x3 )
y0 · + y1 · +
(x0 − x1 ) · (x0 − x2 ) · (x0 − x3 ) (x1 − x0 ) · (x1 − x2 ) · (x1 − x3 )

(x − x0 ) · (x − x1 ) · (x − x3 ) (x − x0 ) · (x − x1 ) · (x − x2 )
y2 · + y3 ·
(x2 − x0 ) · (x2 − x1 ) · (x2 − x3 ) (x3 − x0 ) · (x3 − x1 ) · (x3 − x2 )

logo,
(x − 0, 2) · (x − 0, 4) · (x − 0, 5)
0, 000 · +
(0, 0 − 0, 2) · (0, 0 − 0, 4) · (0, 0 − 0, 5)

2
(x − 0, 0) · (x − 0, 4) · (x − 0, 5)
2, 008 · +
(0, 2 − 0, 0) · (0, 2 − 0, 4) · (0, 2 − 0, 5)

(x − 0, 0) · (x − 0, 2) · (x − 0, 5)
4, 064 · +
(0, 4 − 0, 0) · (0, 4 − 0, 2) · (0, 4 − 0, 5)

(x − 0, 0) · (x − 0, 2) · (x − 0, 4)
5, 125 ·
(0, 5 − 0, 0) · (0, 5 − 0, 2) · (0, 5 − 0, 4)

• P (0, 3)
P (0, 3) ∼
= 3, 027

Exemplo 2
A partir do seguinte conjunto de dados

xi yi
1 52
2 5
4 -5
5 -40
7 10

• determine o polinômio de Lagrange


Solução:

4
4
Y
X (x − xj )
P4 (x) = yi =
i=o
j=0 xi − xj
j ̸= i

(x − x1 ) · (x − x2 ) · (x − x3 ) · (x − x4 )
y0 · +
(x0 − x1 ) · (x0 − x2 ) · (x0 − x3 ) · (x0 − x4 )

(x − x0 ) · (x − x2 ) · (x − x3 ) · (x − x4 )
y1 · +
(x1 − x0 ) · (x1 − x2 ) · (x1 − x3 ) · (x1 − x4 )

(x − x0 ) · (x − x1 ) · (x − x3 ) · (x − x4 )
y2 · +
(x2 − x0 ) · (x2 − x1 ) · (x2 − x3 ) · (x2 − x4 )

(x − x0 ) · (x − x1 ) · (x − x2 ) · (x − x4 )
y3 · +
(x3 − x0 ) · (x3 − x1 ) · (x3 − x2 ) · (x3 − x4 )

(x − x0 ) · (x − x1 ) · (x − x2 ) · (x − x3 )
y4 ·
(x4 − x0 ) · (x4 − x1 ) · (x4 − x2 ) · (x4 − x3 )

logo,
(x − 2) · (x − 4) · (x − 5) · (x − 7) (x − 1) · (x − 4) · (x − 5) · (x − 7)
52 · +5· +
(1 − 2) · (1 − 4) · (1 − 5) · (1 − 7) (2 − 1) · (2 − 4) · (2 − 5) · (2 − 7)

3
(x − 1) · (x − 2) · (x − 5) · (x − 7) (x − 1) · (x − 2) · (x − 4) · (x − 7)
−5 · + −40 · +
(4 − 1) · (4 − 2) · (4 − 5) · (4 − 7) (5 − 1) · (5 − 2) · (5 − 4) · (5 − 7)

(x − 1) · (x − 2) · (x − 4) · (x − 5)
10 ·
(7 − 1) · (7 − 2) · (7 − 4) · (7 − 5)

• use o polinômio obtido, para determinar o valor interpolado em x = 3


Solução: P (3) =
(3 − 2) · (3 − 4) · (3 − 5) · (3 − 7) (3 − 1) · (3 − 4) · (3 − 5) · (3 − 7)
52 · +5· +
(1 − 2) · (1 − 4) · (1 − 5) · (1 − 7) (2 − 1) · (2 − 4) · (2 − 5) · (2 − 7)

(3 − 1) · (3 − 2) · (x − 5) · (3 − 7) (3 − 1) · (3 − 2) · (3 − 4) · (3 − 7)
−5 · + −40 · +
(4 − 1) · (4 − 2) · (4 − 5) · (4 − 7) (5 − 1) · (5 − 2) · (5 − 4) · (5 − 7)

(3 − 1) · (3 − 2) · (3 − 4) · (3 − 5) ∼
10 · =6
(7 − 1) · (7 − 2) · (7 − 4) · (7 − 5)

Interpolador de Newton com diferenças divididas


Seja y = f (x) a função que contem os pontos distintos (xi , yi ), i = 0, 1, 2, ..., n. A
f ′ (x) no ponto x0 é definida

f (x) − f (x0 )
f ′ (x) = lim
x→x0 x − x0
A diferença dividida de primeira ordem é definida como uma aproximação da f ′ (x),
ou seja
f (x) − f (x0 )
f [x, x0 ] =
x − x0
São usada as seguintes notações para diferenças divididas:

f [ ], [ ], ∆y

genericamente, a diferença de medida de ordem n é dada por:

∆n y = f [xi , xi+1 , xi+2 , ..., xi+n ] =

f [xi , xi+1 , xi+2 , ..., xi+n ] − f [xi , xi+1 , xi+2 , ..., xi+n−1 ]
=
xi+n − xi
∆n−1 yi+1 − ∆n−1 yi
xi+n − xi

4
xi yi ∆yi ∆2 yi ∆3 yi ∆4 yi
1 52 -47 14 -6 2
2 5 -5 -10 6
4 -5 -35 20 ——
5 -40 25 ——
7 10 ——

∆0 y1 − ∆0 y0 y1 − y0 5 − 52
∆y0 = = = = −47
x1 − x0 x1 − x0 2−1

∆0 y2 − ∆0 y1 y2 − y1 −5 − 5
∆y1 = = = = −5
x2 − x1 x2 − x1 4−2

∆0 y3 − ∆0 y2 y3 − y2 −40 − (−5)
∆y2 = = = = −35
x3 − x2 x3 − x2 5−4

∆0 y4 − ∆0 y3 y4 − y3 10 − (−40)
∆y3 = = = = 25
x4 − x3 x4 − x3 7−5
——————————————————————————————————————

∆1 y1 − ∆1 y0 −5 − (−47)
∆2 y0 = = = 14
x2 − x0 4−1

∆1 y2 − ∆1 y1 −35 − (−5)
∆2 y1 = = = 10
x3 − x1 5−2

∆1 y3 − ∆1 y2 25 − (−35)
∆2 y2 = = = 20
x4 − x2 7−4
——————————————————————————————————————

∆2 y1 − ∆2 y0 −10 − 14
∆3 y0 = = = −6
x3 − x0 5−1

∆2 y2 − ∆2 y1 20 − (−10)
∆3 y1 = = =6
x4 − x1 7−2
——————————————————————————————————————

∆3 y1 − ∆3 y0 6 − (−6)
∆4 y0 = = =2
x4 − x0 7−1
O polinômio interpolador de Newton, usando as diferenças dividas, pode ser escrito
da seguinte maneira
pn (x) = y0 + ∆y0 (x − x0 ) + ∆2 (x − x0 )(x − x1 ) + ∆3 y0 (x − x0 )(x − x1 )(x − x2 ) + ... +
∆n (x − x0 )...(x − xn−1 )

5
Exemplo
p(x) = 52 + (−47)(x − 1) + 14(x − 1)(x − 2) + (−6)(x − 1)(x − 2)(x − 4) +
2(x − 1)(x − 2)(x − 4)(x − 5)

Exemplo 2

xi yi
6 24
7 25
8 27

Sistema linear
y = a0 + a1 x + a2 x2


a0 + 6a1 + 36a2 = 24

a0 + 7a1 + 49a2 = 25

a0 + 8a1 + 64a2 = 27

2 Por método de gauss

Passo 0
.
 
1 6 36 .. 24 L(0)
 1
1 7 49 ... 25 L(0)

  2
.. (0)
1 8 64 . 27 L3

1
m1 = − = −1
1

Passo 1
.
 
1 6 36 .. 24 L(1)
1 = L1
(0)

0 1 13 ... 1  L(1) = L(0) +m1 · L(0)


 
  2 2 1
.. L
(1)
= L
(0)
+m · L
(0)
0 2 28 . 3 3 3 1 1

2
m1 = − = −2
1

Passo 2
..
 
1 6 36 . 24 L(2)
1 = L1
(1)

0 1 13 ... 1  L(2) = L(1)


 
  2 2
.. L
(2)
= L
(1) (1)
+m2 · L2
0 0 2 . 1 3 3

6
3 Retrosubstituição

a0 + 6a1 + 36a2 = 24

a1 + 13a2 = 1

2a2 = 1

a1 + 13a2 = 1 a0 + 6a1 + 36a2 = 24


2a2 = 1 | |
a1 + 13 · 0, 5 = 1 a0 + 6 · (−5, 5) + 36 · 0, 5 = 24
| |
a1 + 6, 5 = 1 a0 − 33 + 18 = 24
1 | |
a2 = = 0, 5 a1 = 1 − 6, 5 a0 = 24 + 33 − 18
2 | |
a1 = −5, 5 a0 = 39

[39 − 5, 5 0, 5]T

Logo, o polinômio interpolador é:


y = a0 + a1 x + a2 x 2

y = 39 − 5, 5x + 0, 5x2

4 Polinômio interpolador de Lagrange

n
Y
n
X (x − xj )
Pn (x) = yi
i=o
j=0 xi − x j
j ̸= i

(x − x1 )(x − x2 ) (x − x0 )(x − x2 ) (x − x0 )(x − x1 )


P3 (x) = y0 · + y1 · + y2 ·
(x0 − x1 )(x0 − x2 ) (x1 − x0 )(x1 − x2 ) (x2 − x0 )(x2 − x1 )

(x − 6)(x − 8) (x − 6)(x − 8) (x − 6)(x − 7)


P3 (x) = 24 · + 25 · + 27 ·
(6 − 7)(6 − 8) (7 − 6)(7 − 8) (8 − 6)(8 − 7)

x2 − 8x − 7x + 56 x2 − 8x − 6x + 48 x2 − 7x − 6x + 42
P3 (x) = 24 · + 25 · + 27 ·
−1 · −2 1 · −1 2·1

x2 − 15x + 56 x2 − 14x + 48 x2 − 13x + 42


P3 (x) = 24 · + 25 · + 27 ·
2 −1 2

P3 (x) = 12 · (x2 − 15x + 56) − 25 · (x2 − 14x + 48) + 13, 5 · (x2 − 13x + 42)

P3 (x) = 12x2 − 180x + 672 − 25x2 + 350x − 1200 + 13, 5x2 − 175, 5x + 567

P3 (x) = 12x2 − 25x2 + 13, 5x2 − 180x + 350x − 175, 5x + 672 − 1200 + 567

7
P3 (x) = 0, 5x2 − 5, 5x + 39

5 Interpolador de Newton com diferenças divididas

xi yi ∆yi ∆2 yi
6 24 1 0,5
7 25 2
8 27

∆0 y1 − ∆0 y0 y1 − y0 25 − 24
∆y0 = = = =1
x1 − x0 x1 − x0 7−6

∆0 y2 − ∆0 y1 y2 − y1 27 − 25
∆y1 = = = =2
x2 − x1 x2 − x1 8−7

==================================================

∆1 y1 − ∆1 y0 2−1 1
∆2 y0 = = = = 0, 5
x2 − x0 8−6 2

Pn (x) = y0 + ∆y0 (x − x0 ) + ∆2 y0 (x − x0 )(x − x1 ) + ... + ∆n y0 (x − x0 )...(x − xn−1 )

Pn (x) = 24 + 1 · (x − 6) + 0, 5 · (x − 6)(x − 7)

Pn (x) = 24 + x − 6 + 0, 5(x2 − 7x − 6x + 42)

Pn (x) = 24 + x − 6 + 0, 5(x2 − 13x + 42)

Pn (x) = 18 + x + 0, 5x2 − 6, 5x + 21

Pn (x) = 39 − 5, 5x + 0, 5x2

8
6 INTEGRAÇÃO NUMÉRICA

26/05/2023
pag.: 206

A solução numérica de uma integral simples é comumente chamada de quadratura.


Os métodos mais utilizados podem ser classificados em dois grupos:

1. as fórmulas de Newton-côtes, que empregam valores de f (x), onde os valores de x


são igualmente espaçados.

2. a formula de quadratura Gaussiana que utilizada pontos diferentemente espaçados,


onde este espaçamento é determinado por certas propriedades de polinômios orto-
gonais.

Regra dos Trapézios


Para determinação da regra dos trapézios, é utilizado o polinômio de Gregory-Newton
do primeiro grau, ou seja, uma reta.

Z b Z x1
f (x)dx ∼
= P1 (x)dx
a x0 dx = hdz
P1 (x) = y0 + ∆y0 (x − x0 )
Então
onde Z b Z x1

f (x)dx = [y0 + (y1 − y0 ) · z]hdz
y1 − y0 a x0
∆y0 =
x1 − x0 Quando
Então x = a = x0 =⇒ z = 0
x = b = x1 =⇒ z = 1
y1 − y0
P1 (x) = y0 + (x − x0 )
x 1 − x0 Logo
Z b Z x1
Sendo ∼
f (x)dx = h [y0 + (y1 − y0 ) · z]dz
a x0
h = x1 − x 0
1
z2

Temos = h y0 z + (y1 − y0 )
2 0

x − x0 Logo
P1 (x) = y0 + (y1 − y0 )
h    
1 2y0 + y1 − y0
Fazendo h y0 + (y1 − y0 ) = h
2 2
x − x0 h
z= =⇒ x = x0 + zh =⇒ = (y0 + y1 )
h 2

9
Caso Geral
h h h
At ∼
= A1 + A2 + A3 + ... + An = (y0 − y1 ) + (y2 + y3 ) + ... + (yn−2 + yn−1 ) + yn
2 2 2
h h
(y0 + 2y1 + 2y2 + 2y3 + ... + 2yn−1 + yn ) = [y0 + 2(y1 + y2 + y3 + ... + yn−1 ) + yn ]
2 2

1
1º Formula de Simpson ou método de 3

Data 02/06/2023
Pag.: 214

Z b Z x1
I= f (x)dx ∼
= P2 (x)dx
a x0

P2 (x) = y0 + ∆y0 (x − x0 ) + ∆2 y0 (x − x0 )(x − x1 )


Formula:
h
I= [y0 + 4y1 + y2 ]
3
Onde:
b−a
h= ; onde m = nº de subintervalos
m

10
Caso Geral

Z b
I= f (x)dx ∼
= A1 + A2 + A3 + ... + An
a
h h h h
[y0 + 4y1 + y2 ] + [y2 + 4y3 + y4 ] + [y4 + 4y5 + y6 ] + ... + [yn−2 + 4yn−1 + yn ]
3 3 3 3
Fórmula:
h
I= [y0 + 4y1 + y2 + y2 + 4y3 + y4 + y4 + 4y5 + y6 + ... + yn−2 + 4yn−1 + yn ]
3
h
[y0 + 4y1 + 2y2 + +4y3 + 2y4 + ... + 4yn−1 + yn ]
3
h
[y0 + yn + 4(y1 + y3 + ... + yn1 ) + 2(y2 + y4 + ... + yn−2 )]
3

6.1 Exemplo 1
Calcular o valor π Dado pela expressão:
Z 1
dx
π=4 2
0 1+x

1
f (x) =
1 + x2

Com 8 subintervalos.
b−a 1−0
h= = = 0, 125
8 8

11
i xi yi
0 0 1
1 0,125 0,9846
2 0,250 0,9412
3 0,375 0,8767
4 0,500 0,800
5 0,625 0,7191
6 0,750 0,6400
7 0,875 0,5664
8 1 0,5

h
[y0 + yn + 4(y1 + y3 + ... + yn1 ) + 2(y2 + y4 + ... + yn−2 )]
3
Z 1
dx 0, 125
2
= [(1+0, 5)+4(0, 9846+0, 8767+0, 7191+0, 5664)+2(0, 9412+0, 8+0, 64)]
0 1+x 3
= 0, 7854

π∼
= 4 · 0, 7854 ∼
= 3, 1416

Exemplo 2
Z 1
I= x0,1 (1, 2 − x)(1 − e20(x−10) )dx
0

m=4
b−a 1−0 1
h= = = = 0, 25
4 4 4

i xi yi
0 0 0
1 0,25 0,82702
2 0,5 0,65309
3 0,75 0,43429
4 1 0
Z 1
I= x0,1 (1, 2 − x)(1 − e20(x−10) )dx =
0
0, 25
[(0 + 0) + 4(0, 82702 + 0, 43429) + 2(0, 65309)] ∼
= 0, 52929
3

3
2ª Fórmula de Simpson ou método de 8

Gráfico da foto

caso simples
Z b Z x3
I= f (x)dx ∼
= p3 (x)dx
a x0

12
onde

P2 (x) = y0 + ∆y0 (x − x0 ) + ∆2 y0 (x − x0 )(x − x1 ) + ∆3 y0 (x − x0 )(x − x1 )(x − x2 )

Resultado:
3h
I∼
= [y0 + 3y1 + 3y2 + y3 ] Fórmula Simples
8

caso geral
3h 3h
I∼= A1 + A2 + A3 + ... + An = [y0 + 3y1 + 3y2 + y3 ] + [y3 + 3y4 + 3y5 + y6 ] + ... +
8 8
3h
[yn−3 + 3yn−2 + 3yn−1 + yn ]
8
3h
[(y0 + yn ) + 3(y1 + y2 + y4 + y5 + ... + yn−1 ) + 2(y3 + y6 + y9 + ... + yn−3 )]
8

7 Equações diferencias ordinárias (EDO)

data 16/05/2023
pag.: 275

7.1 Equação diferencial

Uma equação que contem as derivadas ou diferenciais de uma ou mais variáveis de-
pendentes, em relação a uma ou mais variáveis independentes, é chamada de equação
diferencial (E.D).

7.2 Classificação pelo tipo

Se uma equação contem somente derivadas ordinárias de uma ou mais variáveis de-
pendentes, com relação a uma única variável independente, ela é chamada de equação
Diferencial Ordinária (E.D.O).

Exemplos
dy
1. − 5y = 1
dx
2. (y − x)dx + 4xdy
dx dv
3. − =x
dy dx
d2 y dy
4. 2
− 2 + 6y = 0
dx dx
Uma equação que envolve as derivadas parciais de uma ou mais variáveis dependentes
de duas ou mais variáveis independentes é chamada de equação diferencial parcial (EDP).

13
exemplo
∂u ∂v
1. =−
∂y ∂x
∂u ∂u
2. x +y =u
∂x ∂y
∂ 2u ∂ 2u ∂u
3. 2
= 2
−2
∂x ∂t ∂t
São equação diferencias parciais.

7.3 Classificação pela ordem

A ordem da derivada de maior ordem em uma equação diferencial é, por definição, a
ordem da equação.
Uma E.D.O geral de enésima ordem é frequentemente representada pelo simbolismo
dn y dy dn−1 y
n
= f (x, y, dx , ..., dxn−1 )
dx
ou
dy n
d y
F (x, y, dx , ..., dxn)

7.4 Classificação por linearidade

Uma equação diferencial e chamada de linear quando pode ser escrita na forma:
dn y dn−1 y dy
an (x) n
+ a n−1 (x) + ... + a1 (x) a0 (x)y = g(x)
dx dxn − 1 dx
Observa que as equações diferencias lineares são caracterizadas por duas propriedades:

1. A variável dependentes e todas as suas derivadas são do primeiro grau: isto é, a
potencia de cada termo envolvendo y é 1.

2. Cada coeficiente depende apenas da variável independente x.

Uma equação que não é linear é chamada de não-linear.

Problema de valor inicial

Do cálculo se conhece a forma com que se apresenta uma E.D.O de ondem n:

y (n) = f (x, y, y ′ , ..., y (n−1) )

Associado a essa equação, podem existir condições cujo o número coincide com a
ordem da E.D.O. Se tais condições se referem a único valor de x, tem-se um problema de
valor inicial (P.V.I). Caso contrário, tem-se um problema de valores de contorno.
Os tipos de P.V.I que será objeto deste estudo, é o mais simples, isto é, de primeira
ordem: (
y ′ = f (x, y)
y(x0 ) = yo = η, η um número dado
Solução numérica de um P.V.I de primeira ordem

14
7.5 Método de Euler

Supondo-se que o P.V.I satisfaça as condições de existência e unicidade, faz-se agora


buscar uma solução numérica. Para isso, tomam-se m subintervalos de [a, b], com m ≥ 1
e faz-se:
b−a
xj = x0 + j · h onde h = , j = 0, 1, 2, ..., m; xj ∈ [a, b]
m

7.6 Série de Taylor

h ′ h2 ′′ h3 ′′′
y(x) = y(x0 ) + y (x0 ) + y (x0 ) + y (x0 ) + ...
1! 2! 3!

Método de Euler

y(x) = y(x0 ) + h · y ′ (x0 ) + O(h2 ) =⇒ y(x) ∼


= y(x0 ) + h · y ′ (x0 )

Fazendo x = x1 e lembrando que y(x0 ) = y0 , y ′ (x0 ) = f (x0 , y(xo )) e y1 ∼


= y(x1 ).

para x = x1

y(x1 ) = y(x0 ) + h · f (x0 , y(x0 )) =⇒ y0 + h · f (x0 , y0 )

para x = x2

y2 = y1 + h · f (x1 , y1 ))

Generalizando

ym = ym−1 + h · f (xm−1 , ym−1 ))

Achar as soluções para o P.V.I

(
y′ = x − y + 2
y(0) = 2
Solução: x0 = 0 ; y0 = 2 ; f (x, y) = x − y + 2

P/i = 1 temos:
x1 = x0 + 1 · h = 0 + 1 · 0.1 = 0.1

y1 = y0 + h · f (x0 , y0 )

calculando f (x0 , y0 ) = x − y + 2 = f (0, 2) = 0 − 2 + 2 = 0

15
∴ y1 = y0 + h · f (x0 , y0 ) = 2 + 0.1 · 0 = 2
=======================================================
P/i = 2 temos:
x2 = x1 + 1 · h = 0.1 + 1 · 0.1 = 0.2

y2 = y1 + h · f (x1 , y1 )

calculando f (x1 , y1 ) = x − y + 2 = f (0.1, 2) = 0.1 − 2 + 2 = 0.1

∴ y2 = y1 + h · f (x1 , y1 ) = 2 + 0.1 · 0.1 = 2.010


=======================================================
P/i = 3 temos:
x3 = x2 + 1 · h = 0.2 + 1 · 0.1 = 0.3

y3 = y2 + h · f (x2 , y2 )

calculando f (x2 , y2 ) = x − y + 2 = f (0.2, 2.010) = 0.2 − 2.010 + 2 = 0.190

∴ y3 = y2 + h · f (x2 , y2 ) = 2.010 + 0.1 · 0.190 = 2.029


=======================================================
P/i = 4 temos:
x4 = x3 + 1 · h = 0.3 + 1 · 0.1 = 0.4

y4 = y3 + h · f (x3 , y3 )

calculando f (x3 , y3 ) = x − y + 2 = f (0.3, 2.029) = 0.3 − 2.029 + 2 = 0.271

∴ y4 = y3 + h · f (x3 , y3 ) = 2.029 + 0.1 · 0.271 = 2.056


=======================================================
P/i = 5 temos:
x5 = x4 + 1 · h = 0.4 + 1 · 0.1 = 0.5

y5 = y4 + h · f (x4 , y4 )

calculando f (x4 , y4 ) = x − y + 2 = f (0.4, 2.056) = 0.4 − 2.056 + 2 = 0.344

∴ y5 = y4 + h · f (x4 , y4 ) = 2.056 + 0.1 · 0.164 = 2.090


=======================================================
P/i = 6 temos:
x6 = x5 + 1 · h = 0.5 + 1 · 0.1 = 0.6

y6 = y5 + h · f (x5 , y5 )

calculando f (x5 , y5 ) = x − y + 2 = f (0.5, 2.252) = 0.5 − 2.252 + 2 = 0.410

∴ y6 = y5 + h · f (x5 , y5 ) = 2.252 + 0.1 · 0.248 = 2.131


=======================================================
P/i = 7 temos:
x7 = x6 + 1 · h = 0.6 + 1 · 0.1 = 0.7

16
y7 = y6 + h · f (x6 , y6 )

calculando f (x6 , y6 ) = x − y + 2 = f (0.6, 2.131) = 0.6 − 2.131 + 2 = 0.469

∴ y7 = y6 + h · f (x6 , y6 ) = 2.131 + 0.1 · 0.469 = 2.178


=======================================================
P/i = 8 temos:
x8 = x7 + 1 · h = 0.7 + 1 · 0.1 = 0.8

y8 = y7 + h · f (x7 , y7 )

calculando f (x7 , y7 ) = x − y + 2 = f (0.7, 2.178) = 0.7 − 2.178 + 2 = 0.522

∴ y8 = y7 + h · f (x7 , y7 ) = 2.178 + 0.1 · 0.522 = 2.230


=======================================================
P/i = 9 temos:
x9 = x8 + 1 · h = 0.7 + 1 · 0.1 = 0.9

y9 = y8 + h · f (x8 , y8 )

calculando f (x8 , y8 ) = x − y + 2 = f (0.8, 2.230) = 0.8 − 2.230 + 2 = 0.570

∴ y9 = y8 + h · f (x8 , y8 ) = 2.230 + 0.1 · 0.570 = 2.287


=======================================================
P/i = 10 temos:
x10 = x9 + 1 · h = 0.8 + 1 · 0.1 = 1.0

y10 = y9 + h · f (x9 , y9 )

calculando f (x9 , y9 ) = x − y + 2 = f (0.9, 2.287) = 0.9 − 2.287 + 2 = 0.613

∴ y10 = y9 + h · f (x9 , y9 ) = 2.287 + 0.1 · 0.613 = 2.348

i x1 y1
0 0.0 2
1 0.1 2
2 0.2 2.010
3 0.3 2.029
4 0.4 2.056
5 0.5 2.090
6 0.6 2.131
7 0.7 2.178
8 0.8 2.230
9 0.9 2.287
10 1.0 2.348

17
Método de Runge-Kutta de 2ª ordem

23/06/2023
pag.: 288

Seja
yj+1 = yj + hϕ(xj , yj , h), j = 0, 1, ..., m − 1
Fazendo
ϕ(xj , yj , h) = αK1 + βK2
e substituindo na equação anterior, temos

yj+1 = yj + h(αK1 + βK2 ), j = 0, 1, ..., m − 1

Sejam (
K1 = f (xj , yj )
.
K2 = f (xj + ph, yj + qhf (xj , yj ))
As constantes α, β, p e q devem ser determinadas para que se obtenha os métodos de
Runge-Kutta de 2ª ordem.
1 1
Para a escolha β = , tem-se α = , p = 1 e q = 1 e o Método de Runge-Kutta (RK2)
2 2
vai ser dado por: 
h
yj+1 = yj + 2 (K1 + K2 )

K1 = f (xj , yj )

K2 = f (xj + h, yj + hf (xj , yj ))

Esse método é conhecido como método de Euler melhorado.


1 1
Para escolha β = 1 tem-se alpha = 0, p = e q = , o RK2 será
2 2

yj+1 = yj + hK2 , j = 0, 1, ..., m − 1

K1 = f (xj , yj )

K2 = f (xj + h2 , yj + h2 f (xj , yj ))

conhecido como método de Euler modificado.

Exemplo 1

(
y′ = N y
y(0) = 1
Analiticamente
Z Z
dy
= N dx =⇒ ln y = N x + c =⇒ y = eN x+c = ec · eN x = C1 · eN x
y
Fazendo
x = 0, y = 1 =⇒ 1 = C1 · eN 0 =⇒ c1 = 1

logo
y = eN x , p/ N = 1 y = ex

18
Usando o método de Euler modificado.
b−a 1−0 1
h= = = = 0, 2
n 5 5
===================================================

p/ j = 0

Temos:


 k1 = f (x0 , y0 ) = y0 = 1
k = f (x + h , y + h · K ) = y + h · K ) = 1 + 0,2 · 1 = 1, 1

2 0 2 0 2 1 0 2 1 2


 y1 = y0 + h · K2 = 1 + 0, 2 · 1, 1 = 1, 22

x1 = x0 + h = 0 + 0, 2
===================================================

p/ j = 1



 K1 = f (x1 , y1 ) = 1, 22
k = f (x + h , y + h · K ) = y + h · K = 1, 22 +
 0,2
2 1 2 1 2 1 1 2 1 2
· 1, 22 = 1, 342


 y2 = y1 + h · K2 = 1, 22 + 0, 2 · 1, 342 = 1, 4884

x2 = x1 + h = 0, 2 + 0, 2 = 0, 4
===================================================

p/ j = 2



 K1 = f (x2 , y2 ) = 1, 4884
k = f (x + h , y + h · K ) = y + h · K = 1, 4884 + 0,2 · 1, 4884 = 1, 63724

2 2 2 2 2 1 2 2 1 2


 y 3 = y 2 + h · K 2 = 1, 4884 + 0, 2 · 1, 63724 = 1, 815848

x3 = x2 + h = 0, 4 + 0, 2 = 0, 6
===================================================

p/ j = 3



 K1 = f (x3 , y3 ) = 1, 815848
k = f (x + h , y + h · K ) = y + h · K = 1, 815848 + 0,2 · 1, 815848 = 1, 9974328

2 3 2 3 2 1 3 2 1 2


 y4 = y3 + h · K2 = 1, 815848 + 0, 2 · 1, 9974328 = 2, 21533456

x4 = x3 + h = 0, 6 + 0, 2 = 0, 8
===================================================

19
p/ j = 4



 K1 = f (x4 , y4 ) = 2, 21533456
k = f (x + h , y + h · K ) = y + h · K = 2, 21533456 + 0,2 · 2, 21533456 = 2, 4368680, 16

2 3 2 4 2 1 4 2 1 2


 y 5 = y4 + h · K 2 = 2, 21533456 + 0, 2 · 2, 4368680, 16 = 2, 702708163

x5 = x4 + h = 0, 8 + 0, 2 = 1, 0

j xj yj
0 0 1
1 0,2 1,22
2 0,4 1,4884
3 0,6 1,815848
4 0,8 2,21533456
5 1,0 2,702708163

Exemplo 2

(
y′ = x − y + 2
y(0) = 2
[0, 1] com h = 0, 25
=====================================================
Fazendo uso, do método RK2 - Euler melhorado
f (x, y) = x − y + 2
b−a 1−0
n= = =4
h 0, 25

p/ j = 0

Temos:


 k1 = f (x0 , y0 ) = y0 = 1
k = f (x + h , y + h · K ) = y + h · K ) = 1 +
 0,2
2 0 2 0 2 1 0 2 1 2
· 1 = 1, 1


 y1 = y 0 + h · K 2 = 1 + 0, 2 · 1, 1 = 1, 22

x1 = x0 + h = 0 + 0, 2

Achar aproximações para a solução do P.V.I

y ′ = y − 2x

y
y(0) = 1

[0, 2] com h = 0, 2

20

You might also like