Hi,
is it possible to calculate trigonometric functions and cubic root (or
other "power"-) values using Common Lisp? Which syntax does apply in
this cases?
Thank you for your replies
Werner
--
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
·······@cad.uni-sb.de fon: ++49 681 302-3607 fax: ++49 681 302-4858
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
In article <·············@cad.uni-sb.de> Werner Britten <·······@cad.uni-sb.de> writes:
> is it possible to calculate trigonometric functions and cubic root (or
> other "power"-) values using Common Lisp? Which syntax does apply in
> this cases?
Sure. (sin x), (cos x), (tan x), etc. There are arc-* versions for
these and hyperbolic versions as well. I don't know what or if there
are any required accuracy behaviors for these or not. Also you have
e^x (exp x) and lnx (log x). Once you have those, you can get any of
the rest of what you want. In particular a^x, a > 0, x in R, =
e^(xlna)
/Jon
--
Jon Anthony
OMI, Belmont, MA 02178
617.484.3383
"Nightmares - Ha! The way my life's been going lately,
Who'd notice?" -- Londo Mollari
Jon S Anthony wrote:
>
> In article <·············@cad.uni-sb.de> Werner Britten <·······@cad.uni-sb.de> writes:
>
> > is it possible to calculate trigonometric functions and cubic root (or
> > other "power"-) values using Common Lisp? Which syntax does apply in
> > this cases?
>
> Sure. (sin x), (cos x), (tan x), etc. There are arc-* versions for
> these and hyperbolic versions as well.
[rest deleted]
(asin x) is arc-sin of x, etc.
* Jon S. Anthony
| Sure. (sin x), (cos x), (tan x), etc. There are arc-* versions for
| these and hyperbolic versions as well. I don't know what or if there
| are any required accuracy behaviors for these or not. Also you have
| e^x (exp x) and lnx (log x). Once you have those, you can get any of
| the rest of what you want. In particular a^x, a > 0, x in R, =
| e^(xlna)
note that Common Lisp has complex numbers. (log x), x < 0, is valid.
(exp (* x (log a))) is more commonly written (expt a x). works when a or x
is 0, too.
#\Erik
--
there was some junk mail in my mailbox. somebody wanted to sell me some
useless gizmo, and kindly supplied an ASCII drawing of it. "actual size",
the caption read. I selected smaller and smaller fonts until it vanished.
In article <·············@cad.uni-sb.de> Werner Britten
<·······@cad.uni-sb.de> writes:
> [using Common Lisp] is it possible to calculate trigonometric functions
The functions SIN, COS, TAN, ATAN (one or two arguments), ACOS, ASIN.
Incidentally, their hyperbolic friends SINH, COSH, TANH, ATANH, ACOSH,
and ASINH are all present, too.
> and cubic root (or other "power"-) values
EXPT is your friend here. e.g., (EXPT X 1/3) will get you cube root.
(Remember that Common Lisp has exact rationals as a datatype, so don't
do anything yucky and inexact like 0.333333 to mean 1/3)
There is a specific function SQRT which you can use in place of (EXPT
X 1/2) just for convenience.
As already noted by Jon Anthony, there is also EXP and LOG (with
optional base, default e) which is pretty useful, too.
For further information, you might find it fun/useful to explore the
Numbers chapter of the Common Lisp HyperSpec(TM), at:
http://www.harlequin.com/books/HyperSpec/FrontMatter/index.html
That will get you to the front page. From there, click on Contents and
Numbers (chapter 12). Alternatively, if you know a function's name
and you're wanting to know if it's there, look in the Symbol Index.