Está en la página 1de 4

CAMPO DE DIRECCIONES DE UNA EDO

(2p) Escriba una función que realice el gráfico del campo de direcciones para un PVI.

(2p) Proponga un PVI. Resuelva por el método de Runge Kutta de cuarto orden.
𝑑𝑦
= 𝑦 sin 𝑥
𝑑𝑥
𝑦(0) = 1
f <- function(x,y) y*sin(x)
F <- function(x) exp(-cos(x)+1)

a <- 0
b <- 2
Yo <- 1
n <- 10
s1 <- rk4(f,a,b,Yo,n)
> s1
x y
[1,] 0.0000000000000000 1.000000000000000
[2,] 0.2000000000000000 1.020133423626997
[3,] 0.4000000000000000 1.082138288895899
[4,] 0.6000000000000001 1.190846288445275
[5,] 0.8000000000000000 1.354310862435795
[6,] 1.0000000000000000 1.583592978432230
[7,] 1.2000000000000000 1.892009362607557
[8,] 1.3999999999999999 2.293383002905165
[9,] 1.5999999999999999 2.798804460409869
[10,] 1.7999999999999998 3.411638384756972
[11,] 1.9999999999999998 4.121163494944167
(2p) Grafique la solución anterior junto a su campo de direcciones.
f <- function(x,y) y*sin(x)
F <- function(x) exp(-cos(x)+1)
a <- 0
b <- 2
Yo <- 1
n <- 10
s1 <- rk4(f,a,b,Yo,n)
plot(s1[,1], s1[,2], pch=15, col="red")
curve(F,a,b, n=401, col="blue",add=TRUE)

También podría gustarte