3
;; This script plots a Lagrange interpolation in a rectangular region.
5
(require version/utils)
6
(when (version<? (version) "5.2")
7
(error "This script requires Racket 5.2 or newer"))
9
(require plot) ; PLoT from Racket 5.2
11
;; v1 through v4 are the values at the corners of the rectangle.
12
(define-values (v1 v2 v3 v4) (values 3 1 4 9))
13
;; L1 and L2 are the dimensions of the rectangle.
14
(define-values (L1 L2) (values 2 2))
16
;; Returns for each (x,y) the interpolated value.
20
(+ (* (+ 1/2 x/L1) (+ 1/2 y/L2) v1)
21
(* (- 1/2 x/L1) (+ 1/2 y/L2) v2)
22
(* (+ 1/2 x/L1) (- 1/2 y/L2) v4)
23
(* (- 1/2 x/L1) (- 1/2 y/L2) v3))))
25
(plot3d (contour-intervals3d z -1 1 -1 1)
26
#:title "x, y interpolation using Lagrange polynomials"
27
#:x-label "x" #:y-label "y" #:z-label "z")
b'\\ No newline at end of file'