Hello. In autolisp, you need to calculate the equation:

f

I wrote a small function:

(defun func (abx) (expt (+ a (- b (/ (cos x) (sin x)))) (/ 1 (abs x))) ) 

As a result of execution (func 1 2 3) prints 1.0, although I figured it out in Excel and there should be 2,155529488. What am I doing wrong?

  • Did you convert x to radians for the cos and sin trigonometric functions? - Kromster
  • No, I thought cos and sin served immediately in radians - Di3go
  • I wrote that way. Verify that you pass the angle values ​​to these functions in exactly the format they expect. - Kromster
  • Well, 3 probably radians are ... in autolisp, is the default division not integer? - vp_arth
  • Yes, by the way, if you enter in the format (func 1.0 2.0 3.0), it displays as it should. The question can be closed, probably. (I don't like this lisp, but they make him teach at the university) - Di3go

1 answer 1

The problem is in types.

(/ 1 (abs 3)) == (/ 1 3)

A division with integer arguments gives an integer result - 1/3 = 0

Check: (func 1 2 3.0)

  • Yes, I already wrote this. Thank you, but I understood it a little bit earlier. - Di3go