-
Notifications
You must be signed in to change notification settings - Fork 1
/
2.11.tex
34 lines (33 loc) · 1.09 KB
/
2.11.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
\documentclass[a4paper,12pt]{article}
\usepackage{listings}
\lstset{language=Lisp}
\begin{document}
\begin{lstlisting}
(define (mul-interval x y)
(let ((l1 (lower-bound x))
(l2 (lower-bound y))
(u1 (upper-bound x))
(u2 (upper-bound y)))
(cond ((and (>= l1 0) (>= l2 0))
(make-interval (* l1 l2) (* u1 u2)))
((and (>= l1 0) (<= u2 0))
(make-interval (* u1 l2) (* u2 l1)))
((and (>= l1 0) (> u2 0))
(make-interval (* u1 l2) (* u1 u2)))
((and (<= u1 0) (<= u2 0))
(make-interval (* u1 u2) (* l1 l2)))
((and (<= u1 0) (>= l2 0))
(make-interval (* u2 l1) (* u1 l2)))
((<= u1 0)
(make-interval (* u2 l1) (* l1 l2)))
((>= l2 0)
(make-interval (* u2 l1) (* u1 u2)))
((<= u2 0)
(make-interval (* u1 l2) (* l1 l2)))
(else
(make-interval (min (* u1 l2)
(* u2 l1))
(max (* l1 l2)
(* u1 u2)))))))
\end{lstlisting}
\end{document}