Function: calc-sel-mult-both-sides
calc-sel-mult-both-sides is an autoloaded, interactive and
byte-compiled function defined in calc-sel.el.gz.
Signature
(calc-sel-mult-both-sides ARG &optional DIVIDE)
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-sel.el.gz
(defun calc-sel-mult-both-sides (arg &optional divide)
(interactive "P")
(calc-wrapper
(calc-preserve-point)
(let* ((no-simp (consp arg))
(num (max 1 (calc-locate-cursor-element (point))))
(calc-sel-reselect calc-keep-selection)
(entry (calc-top num 'entry))
(expr (car entry))
(sel (or (calc-auto-selection entry) expr))
(func (car-safe sel))
alg lhs rhs)
(setq alg (calc-with-default-simplification
(car (calc-do-alg-entry ""
(if divide
"Divide both sides by: "
"Multiply both sides by: ")
nil 'calc-selection-history))))
(and alg
(progn
(if (and (or (eq func '/)
(assq func calc-tweak-eqn-table))
(= (length sel) 3))
(progn
(or (memq func '(/ calcFunc-eq calcFunc-neq))
(if (math-known-nonposp alg)
(progn
(setq func (nth 1 (assq func
calc-tweak-eqn-table)))
(or (math-known-negp alg)
(message "Assuming this factor is nonzero")))
(or (math-known-posp alg)
(if (math-known-nonnegp alg)
(message "Assuming this factor is nonzero")
(message "Assuming this factor is positive")))))
(setq lhs (list (if divide '/ '*) (nth 1 sel) alg)
rhs (list (if divide '/ '*) (nth 2 sel) alg))
(or no-simp
(progn
(setq lhs (math-simplify lhs)
rhs (math-simplify rhs))
(and (eq func '/)
(or (Math-equal (nth 1 sel) 1)
(Math-equal (nth 1 sel) -1))
; (and (memq (car-safe (nth 2 sel)) '(+ -))
; (memq (car-safe alg) '(+ -))))
(unless arg
(setq rhs (math-expand-term rhs))))))
(if (and arg (not no-simp))
(setq rhs (math-simplify
(calcFunc-expand rhs (unless (= arg 0) arg)))))
(setq alg (calc-encase-atoms
(calc-normalize (list func lhs rhs)))))
(setq rhs (list (if divide '* '/) sel alg))
(or no-simp
(setq rhs (math-simplify rhs)))
(setq alg (calc-encase-atoms
(calc-normalize (if divide
(list '/ rhs alg)
(list '* alg rhs))))))
(calc-pop-push-record-list 1 (if divide "div" "mult")
(list (calc-replace-sub-formula
expr sel alg))
num
(list (and calc-sel-reselect alg)))))
(calc-handle-whys))))