1
I’m having a doubt in an example I’m trying to develop in Isp the exercise says:
Modify the function that returns the roots of a second degree so that the real and imaginary parts of the roots return, in the case of they are complex. Suppose the coefficients are real.
I developed it that way :
(defun raizes(a b c)
(let (
(raiz1 (/(+ (* -1 b)(sqrt (- (expt b 2)(* 4 a c ))))(* 2 a)))
(raiz2 (/(- (* -1 b)(sqrt (-(expt b 2)(* 4 a c ))))(* 2 a)))
)
(format t "x1=~,2f" raiz1)
(format t ", x2=~,2f~%" raiz2)
)
)
(raizes 1 -3 -4)
(raizes 1 0 -4)
(raizes 6 11 -35)
(raizes 1 -7 0)
(raizes 5 3 5)
But I can’t do the part that the exercise asks to return the real parts and imagine in case it’s complex.