# Solving Newton’s Law of Cooling Using Maxima

In my previous post, I introduced setting up Maxima, a powerful symbolic computation system, to work with Emacs. This post provides a real example of using Maxima.

I was motivated by this interesting post, introducing the use of Newton’s Law of Cooling in the ranking algorithm of Reddit.  This post (in Chinese) explains more about the derivation of Newton’s Law. I believe the author is good at calculus.  But how if you forgot calculus?  In this case, Maxima would save you!  The following figure illustrates how I use Maxima to derive the Law:

# My Common Lisp Programming Environment

Just for fun, I want to try Common Lisp. (I’ve been using Scheme when I was a student.)

As an ancient language, CL has many implementations. Following Wikipedia, I chose SBCL, a descendent of CMUCL.

It it just like Eclipse for Java, Emacs + SLIME is powerful for Common Lisp (or Scheme). Auto-complete and other stuff are so well supported.

dpans2texi enables us to get help about the word under cursor by simply typing ‘C-h S’.

# Hanoi in Emacs Lisp

Just for fun.

```(defun hanoi (ndisks source dest)
(cond ((= ndisks 1)
(format "%d -> %d, " source dest))
(t
(let ((rest-pole (rest-pole source dest))
(top-disks (- ndisks 1)))
(concat (hanoi top-disks source rest-pole)
(format "%d -> %d, " source dest)
(hanoi top-disks rest-pole dest))))))

(defun rest-pole (source dest)
(- 6 source dest))

(hanoi 5 1 3)
```

# 安装 Emacs 24 咯！

Emacs 24 已经可以开始使用了。它的 Mac OS X 版本支持 fullscreen mode。在 Mac OS X 下可以通过 Homebrew 来安装。方法如下：

```brew update
```

``` (eval-when-compile (require 'cl))
(defun toggle-transparency ()
(interactive)
(if (/=
100)
(set-frame-parameter nil 'alpha '(100 100))
(set-frame-parameter nil 'alpha '(95 50))))
(global-set-key (kbd "C-c t") 'toggle-transparency)
```

```cd ~/.emacs.d
```

```(add-to-list 'load-path "~/.emacs.d/google-maps")
```

# Using GNU Emacs on MacBook (Pro)

You can download pre-compiled GNU Emacs for Mac OS X from http://emacsformacosx.com.

In order to use the Command key as Emacs’s meta key, and Option key as Emacs’ control key, add following two lines to your ~/.emacs file:

```(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'control)
```

# Emacs Viewing and Editing Chinese

I have two versions of Emacs on my iMac (SnowLeopard): Aquamacs and Emacs for Mac OS X. When I open a Chinese text file, Aquamacs can display it, but Emacs for Mac OS X cannot. Fortunately, Google brought me to an old post about editing and viewing Chinese in Emacs/Cygwin, and the method does work for Emacs for Mac OS X.

The code snippet that should be inserted into your .emacs file.

```(if (not (member '("-*-courier new-normal-r-*-*-13-*-*-*-c-*-fontset-chinese"
. "fontset-chinese") fontset-alias-alist))
(progn
(create-fontset-from-fontset-spec
"-*-courier new-normal-r-*-*-13-*-*-*-c-*-fontset-chinese,
chinese-gb2312:-*-MS Song-normal-r-*-*-16-*-*-*-c-*-gb2312*-*,
chinese-big5-1:-*-MingLiU-normal-r-*-*-16-*-*-*-c-*-big5*-*,
chinese-big5-2:-*-MingLiU-normal-r-*-*-16-*-*-*-c-*-big5*-*" t)

(setq default-frame-alist
(append
'((font . "fontset-chinese"))
default-frame-alist))
)
)```

Above method is not enough to GNU Emacs for Windows.  I added the following encoding settings (copied from this post):

```(set-language-environment 'Chinese-GB)
(set-keyboard-coding-system 'euc-cn)
(set-clipboard-coding-system 'euc-cn)
(set-terminal-coding-system 'euc-cn)
(set-buffer-file-coding-system 'euc-cn)
(set-selection-coding-system 'euc-cn)
(modify-coding-system-alist 'process "*" 'euc-cn)
(setq default-process-coding-system
'(euc-cn . euc-cn))
(setq-default pathname-coding-system 'euc-cn)
```