;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; ;;;; Name: math.lisp ;;;; Purpose: General purpose math functions ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Nov 2002 ;;;; ;;;; $Id: math.lisp,v 1.3 2003/04/28 23:51:59 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; ;;;; KMRCL users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* (in-package :kmrcl) (defun deriv (f dx) #'(lambda (x) (/ (- (funcall f (+ x dx)) (funcall f x)) dx))) (defun sin^ (x) (funcall (deriv #'sin 1d-8) x)) ;;; (sin^ pi) (defmacro ensure-integer (obj) "Ensure object is an integer. If it is a string, then parse it" `(if (stringp ,obj) (parse-integer ,obj) ,obj))