Re: languages for CAS .. was: Re: Which is the best CAS
- From: Richard Fateman <fateman@xxxxxxxxxxxxxxx>
- Date: Thu, 21 May 2009 22:02:44 -0700
Herman Rubin wrote:
In article <4A12E9BE.6060706@xxxxxxxxxxxxxxx>,
Richard Fateman <fateman@xxxxxxxxxxxxxxx> wrote:
Herman Rubin wrote:
.. snip...
No; I mean that if a function produced three appropriately
designated outputs, they are stored as convenient. For
example, if one wants to get the exponent and the normalized
mantissa of a float, the way to write it would be
(xp, man) = unpack(x).a
In common lisp one can write
(multiple-value-setq
(significand exponent sign)
(decode-float -3.1415))
which I think does exactly what you want. Namely,
the variable significand is 0.785375, the exponent is 2 and the sign is -1.0
and
(* significand (expt 2 exponent) sign) is -3.1415
Now look at the length of your expression and the
length of mine.
(defmacro mvs(a b)`(multiple-value-setq ,a ,b))
;; abbreviate, if you use it often
(defmacro df(a) `(decode-float ,a))
;; abbreviate, if you use it often
(mvs (m xp s) (df x)) ;; my code, and it gives the sign, too
(xp, man) = unpack(x).a ;; your code is longer.
You can do it with Lisp, but it is
clumsly, and "computer jargon" instead of mathematical
coding. The simplicity of the mathematical code for
humans is important.
Using "=" for assignment is computer jargon, as is unpack(x).a which is certainly no mathematics I'm familiar with.
If one had an array, and wanted the mean, standard deviation,
and range, one might use the call
(m,sd, r) =summary(z).
A common lisp programmer could define summary this way
(just a sketch, obviously)
(defun summary(z)
(values (/ (apply #'+ z)(length z)) ;;average.
;; compute standard deviation here
;; compute range here)
Why should we read the list three times? Reading a
list is much slower than computations.
That's why I said a sketch. Here's a more complete program that goes through the list once.
(defun summary(z)
(let ((max most-negative-double-float)
(min most-positive-double-float)
(sum 0)(len 0)(sumsq 0) av)
(dolist (r z (values (setf av (/ sum len));average
(sqrt (- (/ sumsq len)(* av av)));sd
(list min max)))
(incf sum r)
(incf sumsq (* r r))
(incf len)
(if (> r max)(setf max r))
(if (< r min)(setf min r)))))
For people who are under the mistaken impression that it is tedious to count parentheses, let me point out that the editor does most of the work, and also indents.
An oversimplification:
The argument in favor of Axiom is that it might be better if you were using a kind of alternative universe of programming in which you have, instead of (or really, in addition to) data structures or types such as byte, word, array, record, ... the notion of "categories" like monoid, group, ring, field, polynomial, and constructors for new categories.
I am assuming that the language will allow any type one wants; mathematicians have no problems with this.
I do not understand this statement. My impression is that the typical mathematician, for reasons I do not understand, has a great deal of trouble writing computer programs. Not all mathematicians of course.
Some computer programmers have a great deal of trouble with mathematics. Not all programmers of course :)
.
- Follow-Ups:
- Re: languages for CAS .. was: Re: Which is the best CAS
- From: Herman Rubin
- Re: languages for CAS .. was: Re: Which is the best CAS
- References:
- Which is the best CAS
- From: Francogrex
- Re: languages for CAS .. was: Re: Which is the best CAS
- From: Martin Rubey
- Re: languages for CAS .. was: Re: Which is the best CAS
- From: Herman Rubin
- Re: languages for CAS .. was: Re: Which is the best CAS
- From: Richard Fateman
- Re: languages for CAS .. was: Re: Which is the best CAS
- From: Herman Rubin
- Which is the best CAS
- Prev by Date: Re: languages for CAS .. was: Re: Which is the best CAS
- Next by Date: Premium Snake Bite Kit
- Previous by thread: Re: languages for CAS .. was: Re: Which is the best CAS
- Next by thread: Re: languages for CAS .. was: Re: Which is the best CAS
- Index(es):
Relevant Pages
|