Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
8
Task/Runge-Kutta-method/Racket/runge-kutta-method-1.rkt
Normal file
8
Task/Runge-Kutta-method/Racket/runge-kutta-method-1.rkt
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(define (RK4 F δt)
|
||||
(λ (t y)
|
||||
(define δy1 (* δt (F t y)))
|
||||
(define δy2 (* δt (F (+ t (* 1/2 δt)) (+ y (* 1/2 δy1)))))
|
||||
(define δy3 (* δt (F (+ t (* 1/2 δt)) (+ y (* 1/2 δy2)))))
|
||||
(define δy4 (* δt (F (+ t δt) (+ y δy1))))
|
||||
(list (+ t δt)
|
||||
(+ y (* 1/6 (+ δy1 (* 2 δy2) (* 2 δy3) δy4))))))
|
||||
5
Task/Runge-Kutta-method/Racket/runge-kutta-method-2.rkt
Normal file
5
Task/Runge-Kutta-method/Racket/runge-kutta-method-2.rkt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(define ((step-subdivision n method) F h)
|
||||
(λ (x . y) (last (ODE-solve F (cons x y)
|
||||
#:x-max (+ x h)
|
||||
#:step (/ h n)
|
||||
#:method method))))
|
||||
10
Task/Runge-Kutta-method/Racket/runge-kutta-method-3.rkt
Normal file
10
Task/Runge-Kutta-method/Racket/runge-kutta-method-3.rkt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(define (F t y) (* t (sqrt y)))
|
||||
|
||||
(define (exact-solution t) (* 1/16 (sqr (+ 4 (sqr t)))))
|
||||
|
||||
(define numeric-solution
|
||||
(ODE-solve F '(0 1) #:x-max 10 #:step 1 #:method (step-subdivision 10 RK4)))
|
||||
|
||||
(for ([s numeric-solution])
|
||||
(match-define (list t y) s)
|
||||
(printf "t=~a\ty=~a\terror=~a\n" t y (- y (exact-solution t))))
|
||||
4
Task/Runge-Kutta-method/Racket/runge-kutta-method-4.rkt
Normal file
4
Task/Runge-Kutta-method/Racket/runge-kutta-method-4.rkt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
> (require plot)
|
||||
> (plot (list (function exact-solution 0 10 #:label "Exact solution")
|
||||
(points numeric-solution #:label "Runge-Kutta method"))
|
||||
#:x-label "t" #:y-label "y(t)")
|
||||
Loading…
Add table
Add a link
Reference in a new issue