| 1 | ;; Lambert's W functions |
|---|
| 2 | ;; Liam Healy, Fri Apr 28 2006 - 20:40 |
|---|
| 3 | ;; Time-stamp: <2008-02-16 22:19:40EST lambert.lisp> |
|---|
| 4 | ;; $Id$ |
|---|
| 5 | |
|---|
| 6 | (in-package :gsl) |
|---|
| 7 | |
|---|
| 8 | ;;; FDL |
|---|
| 9 | ;;; Lambert's W functions, W(x), are defined to be solutions |
|---|
| 10 | ;;; of the equation W(x) exp(W(x)) = x. This function has |
|---|
| 11 | ;;; multiple branches for x < 0; however, it has only |
|---|
| 12 | ;;; two real-valued branches. We define W_0(x) to be the |
|---|
| 13 | ;;; principal branch, where W > -1 for x < 0, and |
|---|
| 14 | ;;; W_{-1}(x) |
|---|
| 15 | ;;; W_{-1}(x) to be the other real branch, where |
|---|
| 16 | ;;; W < -1 for x < 0. |
|---|
| 17 | |
|---|
| 18 | (defmfun lambert-W0 (x) |
|---|
| 19 | "gsl_sf_lambert_W0_e" ((x :double) (ret sf-result)) |
|---|
| 20 | :documentation ; FDL |
|---|
| 21 | "The principal branch of the Lambert W function, W_0(x).") |
|---|
| 22 | |
|---|
| 23 | (defmfun lambert-Wm1 (x) |
|---|
| 24 | "gsl_sf_lambert_Wm1_e" ((x :double) (ret sf-result)) |
|---|
| 25 | :documentation ; FDL |
|---|
| 26 | "The secondary real-valued branch of the Lambert W function, |
|---|
| 27 | W_{-1}(x).") |
|---|
| 28 | |
|---|
| 29 | ;;;;**************************************************************************** |
|---|
| 30 | ;;;; Examples and unit test |
|---|
| 31 | ;;;;**************************************************************************** |
|---|
| 32 | |
|---|
| 33 | #| |
|---|
| 34 | (make-tests lambert |
|---|
| 35 | (lambert-W0 1.0d0) |
|---|
| 36 | (lambert-Wm1 1.0d0)) |
|---|
| 37 | |# |
|---|
| 38 | |
|---|
| 39 | (LISP-UNIT:DEFINE-TEST LAMBERT |
|---|
| 40 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 41 | (LIST 0.5671432904097838d0 2.518622157098455d-16) |
|---|
| 42 | (MULTIPLE-VALUE-LIST (LAMBERT-W0 1.0d0))) |
|---|
| 43 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 44 | (LIST 0.5671432904097838d0 2.518622157098455d-16) |
|---|
| 45 | (MULTIPLE-VALUE-LIST (LAMBERT-WM1 1.0d0)))) |
|---|