원본 파일(SVG 파일, 실제 크기 720 × 450 픽셀, 파일 크기: 54 KB)

파일 설명

설명
Deutsch: Runge-Kutta Methoden für die Differentialgleichung y'=sin(t)^2*y
English: Runge–Kutta, Heun and Euler methods for the differential equation y'=sin(t)^2*y
날짜
출처
저자

Svchb


이 그림은 수정된 그림으로, 원래 그림에서 디지털 변환이 이루어진 그림입니다. 수정 사항 : converted into svg. 원래의 그림 : RK Verfahren.png. 수정판 제작자 Tobi.

 
이 W3C-불확실 chart R(으)로 제작되었습니다.

R Code

# differential equation y'=sin(t)^2 * y
dy <- function(t, y) sin(t)^2 * y

# exact solution 
exact <- function(t) 2 * exp(0.5*(t - sin(t)*cos(t)))

# euler's method
euler <- function(t, y, h, fun) {
  y1 <- y + h*fun(t, y)
  return(c(t + h, y1))
}

# heun's method
heun <- function(t, y, h, fun) {
  yp <- y + h*fun(t, y)
  y1 <- y + 0.5*h * (fun(t, y) + fun(t+h, yp))
  return(c(t + h, y1))
}

# classical Runge–Kutta method
runge <- function(t, y, h, fun) {
  y0 <- fun(t, y)
  ya <- fun(t+h/2, y + h/2*y0)
  yb <- fun(t+h/2, y + h/2*ya)
  yc <- fun(t+h, y + h*yb)
  
  y1 <- y + h/6*(y0 + 2*(ya+yb) + yc)
  return(c(t + h, y1))
}

# step size = 0.5, last value = 5
h <- 0.5
niter <- 5/h
run <- eul2 <- eul <- heu <- data.frame(t=0, y=exact(0))

for(i in seq_len(niter)+1) {
  eul[i, ] <- euler(t=eul$t[i-1], y=eul$y[i-1], h=h, fun=dy)
  heu[i, ] <- heun (t=heu$t[i-1], y=heu$y[i-1], h=h, fun=dy)
  run[i, ] <- runge(t=run$t[i-1], y=run$y[i-1], h=h, fun=dy)
}

# euler's method with reduced step size
h <- 0.25
niter <- 5/h
for(i in seq_len(niter)+1) {
  eul2[i, ] <- euler(t=eul2$t[i-1], y=eul2$y[i-1], h=h, fun=dy)
}

# evaluating exact solution at 
t <- seq(0, 5, 0.1)

# concatenating the methods into a data.frame
odesolve <- rbind(data.frame(t=t, y=exact(t), method="Exact Solution"),
                  data.frame(run,  method="Runge-Kutta method"),
                  data.frame(heu,  method="Heun's method"),
                  data.frame(eul2, method="Euler's method (reduced step size)"),
                  data.frame(eul,  method="Euler's method"))

# translating into german
odesolve$method <- factor(odesolve$method, 
                          levels=c("Exact Solution", "Runge-Kutta method", 
                                   "Heun's method", 
                                   "Euler's method (reduced step size)", 
                                   "Euler's method"),
                          labels=c("Exakte Lösung", "Klassisches Runge-Kutta", 
                                   "Heun", "Euler (halbe Schrittweite)", 
                                   "Euler"))

library(ggplot2)
p <- ggplot(odesolve, aes(x=t, y=y, col=method)) +   geom_line() + 
  geom_point(data=subset(odesolve, as.numeric(method)!=1)) +
  scale_color_discrete("") + 
  theme_bw() + theme(legend.position=c(0.02, 1), legend.justification=c(0, 1))

ggsave("runge-kutta.svg", width=8, height=6, plot=p)

라이선스

나는 아래 작품의 저작권자로서, 이 저작물을 다음과 같은 라이선스로 배포합니다:
w:ko:크리에이티브 커먼즈
저작자표시 동일조건변경허락
이용자는 다음의 권리를 갖습니다:
  • 공유 및 이용 – 저작물의 복제, 배포, 전시, 공연 및 공중송신
  • 재창작 – 저작물의 개작, 수정, 2차적저작물 창작
다음과 같은 조건을 따라야 합니다:
  • 저작자표시 – 적절한 저작자 표시를 제공하고, 라이센스에 대한 링크를 제공하고, 변경사항이 있는지를 표시해야 합니다. 당신은 합리적인 방식으로 표시할 수 있지만, 어떤 방식으로든 사용권 허가자가 당신 또는 당신의 사용을 지지하는 방식으로 표시할 수 없습니다.
  • 동일조건변경허락 – 만약 당신이 이 저작물을 리믹스 또는 변형하거나 이 저작물을 기반으로 제작하는 경우, 당신은 당신의 기여물을 원저작물과 동일하거나 호환 가능한 라이선스에 따라 배포하여야 합니다.

설명

이 파일이 나타내는 바에 대한 한 줄 설명을 추가합니다

이 파일에 묘사된 항목

다음을 묘사함

image/svg+xml

파일 역사

날짜/시간 링크를 클릭하면 해당 시간의 파일을 볼 수 있습니다.

날짜/시간섬네일크기사용자설명
현재2014년 5월 11일 (일) 22:372014년 5월 11일 (일) 22:37 판의 섬네일720 × 450 (54 KB)T.gausterfixed typo, adjusted width and height
2014년 5월 11일 (일) 18:492014년 5월 11일 (일) 18:49 판의 섬네일720 × 540 (54 KB)T.gausterUser created page with UploadWizard

다음 문서 1개가 이 파일을 사용하고 있습니다:

이 파일을 사용하고 있는 모든 위키의 문서 목록

다음 위키에서 이 파일을 사용하고 있습니다:

메타데이터