I've been having quite a bit of trouble loading a package I wrote. I've followed the suggestions on related questions on this site, as well as on Mathematica's own pages, and still nothing has worked. This is my package code:

(* General error propagation formula *)

fError::usage = 
  "Calculate the error in a function f[{x1,x2,...}] with uncertainties {dx1,dx2,...}."


fError[f_, xi__, dx__] := 
  Sum[(D[f[xi], xi[[i]]]*dx[[i]])^2, {i, 1, Length[xi]}]^(1/2);

fErrorTest[x_] := Module[{a = 3}, x^3 - a];



And then I try to load it as such:

<< pathToFile/errorpropagation.m
g[{x_, y_}] := x^2 + x y;
fError[g, {x, y}, {dx, dy}]

I've tried different variants of whether the << command takes a string or not, and relative and full path names, but had no success. The package has worked for me if I open it and evaluate the cells in the package, but the whole point of writing a package was to avoid manual evaluation every time.

  • $\begingroup$ Did you make all the evaluatable cells in your package initialization cells before you saved as an .m file? $\endgroup$
    – m_goldberg
    May 1 '14 at 21:41
  • $\begingroup$ @m_goldberg That worked perfectly, thanks. That's definitely not on the Mathematica page. $\endgroup$ May 1 '14 at 21:44
  • 1
    $\begingroup$ Possible duplicate of this question $\endgroup$
    – m_goldberg
    May 1 '14 at 22:01
  • $\begingroup$ A bit more general: mathematica.stackexchange.com/questions/16793/… $\endgroup$ May 1 '14 at 23:16

Browse other questions tagged or ask your own question.