Subject: bug#15511: calc fit not working in emacs 24.3

From: Devin Homan <[email-masked]>
Date: Thu, 03 Oct 2013 01:03:44 -0800

This bug should be reproducible by following the info example "12.8.1 Linear Fits". The function fit
function appears to not be working in Emacs 24.3.1 but it works in 23.4.1. math-general-fit calls
math-rewrite, which produces a result that is rejected by math-general-fit.

(calcFunc-fit '(+ (var a var-a) (* (var b var-b) (var x var-x))) '(var x var-x) '(vec (var a var-a)
(var b var-b)) '(vec (vec 1 2 3 4 5) (vec 5 7 9 11 13)))

should result in (+ (float 3 0) (* (float 2 0) (var x var-x))).

math-rewrite returns

in Emacs 24

(calcFunc-fitsystem 0 (vec (- (+ (* (calcFunc-fitparam 2) (calcFunc-fitvar 1)) (calcFunc-fitparam
1)) (calcFunc-fitvar 2))) (vec (calcFunc-eq (calcFunc-fitdummy 1) 1)) 0)

in Emacs 23

(calcFunc-fitsystem (calcFunc-fitvar 2) (vec 1 (calcFunc-fitvar 1)) (vec (calcFunc-fitdummy 1)
(calcFunc-fitdummy 2)))

The erroneous result is being returned on line 1664 of calcalg3.el in 24.3.1
"expr (math-rewrite (list 'calcFunc-fitmodel expr)",
which is line 1665 in 23.4.1.