(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



(* ::Input::Initialization:: *)
GenericPoints[P_]:=Table[{x[k],y[k]},{k,1,P}]


(* ::Input::Initialization:: *)
Pol3[x_]:=Simplify[InterpolatingPolynomial[GenericPoints[3],x]]
PolN[x_,N_]:=Simplify[InterpolatingPolynomial[GenericPoints[N],x]]


(* ::Input::Initialization:: *)
replaceGenericPoints[listofpoints_]:=Module[{repl,len=Length[listofpoints]},
repl=Flatten[Table[{x[i]->listofpoints[[All,1]][[i]],y[i]->listofpoints[[All,2]][[i]]},{i,1,len}]]
]
PolNpoints[deg_,listofpoints_,z_]:=Module[{repl,len=Length[listofpoints]},
If[deg==len,
(*repl=Flatten[Table[{x[i]\[Rule]listofpoints\[LeftDoubleBracket]All,1\[RightDoubleBracket]\[LeftDoubleBracket]i\[RightDoubleBracket],y[i]\[Rule]listofpoints\[LeftDoubleBracket]All,2\[RightDoubleBracket]\[LeftDoubleBracket]i\[RightDoubleBracket]},{i,1,len}]];*)
repl=replaceGenericPoints[listofpoints];
(*Print[repl];*)
PolN[z,deg]//.repl,
Print["Degree of polynomial requested, deg=",deg," is too high/low for the number of points, N=",len,", to constrain it."];
PolNpoints[len,listofpoints,z]
]
]
