Function: math-solve-for

math-solve-for is an autoloaded and byte-compiled function defined in calcalg2.el.gz.

Signature

(math-solve-for LHS RHS SOLVE-VAR SOLVE-FULL &optional SIGN)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calcalg2.el.gz
(defun math-solve-for (lhs rhs solve-var solve-full &optional sign)
  (let ((math-solve-var solve-var)
        (math-solve-full solve-full))
  (if (math-expr-contains rhs solve-var)
      (math-solve-for (math-sub lhs rhs) 0 solve-var solve-full)
    (and (math-expr-contains lhs solve-var)
	 (math-with-extra-prec 1
	   (let* ((math-poly-base-variable math-solve-var)
		  (res (math-try-solve-for lhs rhs sign)))
	     (if (and (eq math-solve-full 'all)
		      (math-known-realp math-solve-var))
		 (let ((old-len (length res))
		       new-len)
		   (setq res (delq nil
                                   (mapcar (lambda (x)
                                             (and (not (memq (car-safe x)
                                                             '(cplx polar)))
                                                  x))
					   res))
			 new-len (length res))
		   (if (< new-len old-len)
		       (calc-record-why (if (= new-len 1)
					    "*All solutions were complex"
					  (format
					   "*Omitted %d complex solutions"
					   (- old-len new-len)))))))
	     res))))))