 
  fi; 
 
  debug_print(procname,"substitution list",2,_subslist); 
 
  #---------------------- 
  # check the solution(s) 
  #---------------------- 
  if type(solset,list(list)) then  #multiple solutions 
    debug_print(procname,"Verifying the ".(nops(solset))." solutions...",1); 
    goodsols := []; 
    for k from 1 to nops(solset) do 
      tmp := expand(subs(_subslist,eval(eqs,solset[k]))); 
      if not type(tmp,list(0=0)) then 
        debug_print(procname,"Solution ".k." is invalid!",0,solset[k]); 
        debug_print(procname,"Solution ".k." substituted into normal eqs",0,eqs); 
        debug_print(procname,"Throwing out solution ".k,0); 
      else 
        goodsols := [op(goodsols),solset[k]]; 
      fi; 
    od; 
    solset := goodsols; 
    if nops(solset)=1 then  
      solset := op(solset);  
    fi; 
  else                             #single solution 
    debug_print(procname,"Verifying the solution...",1); 
    eqs := factor(expand(subs(_subslist,eval(eqs,solset)))); 
    if not type(eqs,list(0=0)) then 
      debug_print(procname,"Solution substituted into normal eqs",0,eqs); 
      ERROR("Invalid solution!"); 
    fi; 
  fi; 
 
  if time()-time0 > 10 then 
    debug_print(procname,"Done!",1); 
  fi; 
  solset; 
end:
4. Examples
Polynomial of degree 1
We start with simple linear regression to check the program.  We set the procedure's "chattiness" to 
maximum verbosity.  The solution appears as the last bracketed expression.
 := 
printlevel
4
(
)
leastsqrs
, , ,
 = 
y
 + 
A B t
i
t i [
]
,
A B
leastsqrs[0]: i,t,y,ispoly,chi2
, , ,
,
i t
i
y
i
true
 = 
i 1
N
(
)
 -   - 
y
i
A B t
i
2
Page 8