(* Using linear or non-linear list square fit for USD/EUR rates *) (* To run on command line: math -run "< "Data points", Prolog-> AbsolutePointSize [1] ] (* Do linear least square fit to a 3rd degree polynomial*) fit = Fit[data, {1, x, x^2, x^3}, x] fit2 = NonlinearModelFit[data, K0 + 0.1*Sin[x/30 +K2 ], {K0, K2}, x ] (* having too many fitting constants may not be a good idea *) (* fit2 = NonlinearModelFit[data, K0 + K3*Sin[x/K4 +K2 ], {K0, K2, K3, K4}, x ] *) (* Perhaps one can combine the two? *) Print[] Print[fit] Print[] Print[Normal[fit2]] plotfit = Plot[fit, {x, a, b}, PlotStyle->{Hue[0.5], Thickness[0.005]}, PlotLabel-> "Least Square", DisplayFunction -> Identity ] plotfit2 = Plot[fit2[x], {x, a, b}, PlotStyle->{Hue[0.8], Thickness[0.005]}, PlotLabel-> "Least Square", DisplayFunction -> Identity ] (* Show only data and the fit *) Show[plotdata, plotfit, PlotLabel -> FontForm["circles - data, blue - Least S. Fit ", {"Courier", 15}], Prolog-> AbsolutePointSize[2], DisplayFunction -> $DisplayFunction ] Show[plotdata, plotfit2, PlotLabel -> FontForm["circles - data, blue - Least S. Fit ", {"Courier", 15}], Prolog-> AbsolutePointSize[2], DisplayFunction -> $DisplayFunction ] Clear[data] Clear[fit] Clear[fit2]