[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MIT-Scheme-users] Constructing a differential function with ScmUtils
From: |
David Gray |
Subject: |
[MIT-Scheme-users] Constructing a differential function with ScmUtils |
Date: |
Thu, 9 Mar 2017 10:21:10 +0200 |
I’m doing some calculations for GVD in various dielectrics, and I thought to
ask here if anyone knows if there is a less clunky method of constructing the
differential function with a list of constants:
;;; Refractive Index given Sellmeier coefficients at wavelength in microns
(define (n p1 p2 p3 p4 p5 p6 l)
(define (d t b l2)
(/ (* t l2) (- l2 b)))
(let ((l2 (square l)))
(sqrt (+ 1 (d p1 p2 l2) (d p3 p4 l2) (d p5 p6 l2)))))
(define nofx (lambda (x) (n 'p1 'p2 'p3 'p4 'p5 'p6 x)))
#| test symbolics
(nofx 'x)
((D nofx) 'x) ; first derivative
((D (D nofx)) 'x) ; second derivative - pretty slow from here on but who
cares
((D (D (D nofx))) 'x) ; third derivative
|#
;;; BK7 glass coefficients from https://refractiveindex.info
(define bk7 '(1.03961212 6.00069867e-3 0.231792344 2.00179144e-2 1.01046945
1.03560653e2))
;;; redefine nods using actual constants
(define nofx (lambda (x) (n (ref bk7 0)(ref bk7 1)(ref bk7 2)(ref bk7 3)(ref
bk7 4)(ref bk7 5) x)))
#| numerics
(define l 0.8) ;; Ti:Saph laser wavelength
(nofx l) ;; 1.51078
((D nofx) l) ;; -1.9842e-2
((D (D nofx)) l) ;; 0.04925
((D (D (D nofx))) l) ;; -.28889
All seem pretty consistent with literature up to here.
|#
Regards
Dave
- [MIT-Scheme-users] Constructing a differential function with ScmUtils,
David Gray <=