From: lin8080 <lin8080@fr...>  20030717 06:52:35

Kaz Kylheku schrieb: > On Mon, 14 Jul 2003, lin8080 wrote: > > Now, when I type in (rechne (sin 30)) it returns some numbers in the way > > like complex numbers are shown. And I think there is something going > > wrong ... > Radians are units based on the idea that the radius of a circle > represents one unit going around the circle. Hence there are (* 2 pi) > radians to 360 degrees, and 30 degrees is (/ pi 6) radians or > about 0.524. Yes, I know. I normaly use 57.3 to transform Grad in Radians. (x[rad] = x * 57.3 [grad], y[grad] = y / 57.3 [rad]). Doing so, I get other results (sin (/ 30 57.3)) vs (sin 30). > The reason some numbers coming out of your program are shown in complex > notation is because they really *are* complex. The value of (sin 30) is > approx 0.988. The square root of that is a negative number. This is what HyperSpec says in section SQRT, ISQRT (file /body/fun_sqrtcm_isqrt.html.) "... if the number is not a complex but is negative, then the result is a complex" (12.1. ff). This case seems to be clear. The mathematicans also say that a negativ sqrt is complex (right?), but the same mathematicans say that (sqrt) is the reverse function of (* zahl zahl) (which will returned only positiv numbers) and they also describe for what kind of numbers this is valid. The practical reason why there is +, in trigononic functions, is to say where the point of the graph is in the xysystem. And for that no complex is needed, only 2 values. So the question should be: is there a way to suppress the complex number representation in negative trigonomic values, when a sqrt is involved? > In some programming languages, taking the square root of a negative > number triggers an error. Lisp is different and better; it produces a > complex number. This is one of the advantages of dynamic typing. Yes, right. I also see simple 0 instead of an error (some small schemelisps). > > (setq rechen (makearray '(9 3))) > This works as casual use in CLISP and other Lisp implementations, but > in serious Lisp programs you should use DEFVAR, DEFPARAMETER for > defining global variables. > It's not welldefined behavior to SETQ or SETF a symbol which has no > previously defined variable binding. Oh, this is more like my privat convention. For variables/symbols that will not change I use the old SETQ. The rest is SETF. And don't worry, this code will not find a way into a package. It is only a quick hack to see a series of digits is equal or not. The file names "zahl5.lsp" and is executed as needed with (load ".."). Only when playing around I realised the complex representation in trigonomic functions and I reported this, because it makes me wonder how to interpret complex (sin x) values and while there is a similar mail with maxima (sin x) here. stefan 