[Date Index] [Thread Index] [Author Index]
Re: Tips for writing correct, non trivial Mathematica Libraries
>> of x + y to be Sqrt[x y], it should be (x + y)^1 = x+ y > > No, it shouldn't be. There is no such thing as a mean of a number or an algebraic expression. What you would expect is But something like Times should be ok? It think it's a reasonable matter of convention whether someone feels like a definition for geometric mean should expect a single vector argument, or as multiple arguments e.g. geom[x,y,z,=85] but I'll admit we're quibbling at this point and move on. > > Clear[geom] > > geom::nonlist = > "The argument `1` is neither a non-empty vector nor a non-empty matrix"; > > geom[ls_] /;If[Head[ls] === List, True, Message[geom::nonlist, x]; False] := > Apply[Times, ls]^(1/Length[ls]) Awesome -- this is what I was curious about! Thanks for taking the time.