Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8023

Re: Tips for writing correct, non trivial Mathematica Libraries

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.ripco.com!news.glorb.com!indigo.octanews.net!news-out.octanews.net!mauve.octanews.net!newsfeeds.sol.net!post2.nntp.sol.net!posts.news.twtelecom.net!nnrp2.twtelecom.net!not-for-mail
From "l.i.b." <nehal.alum@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Tips for writing correct, non trivial Mathematica Libraries
Date Fri, 20 Jan 2012 06:47:25 +0000 (UTC)
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <jfb2lt$hit$1@smc.vnet.net> (permalink)
References <jf8qj3$3of$1@smc.vnet.net>
Lines 46
NNTP-Posting-Date 20 Jan 2012 06:47:52 GMT
NNTP-Posting-Host cabf2948.news.twtelecom.net
X-Trace DXC=QV^RRm[dm236B[BDadA[j7C_A=>8kQj6=hHXa^^g6TZ4>Mj6^Dm9g`>EFiONJ7[Go6?fmK:nH6@e4
X-Complaints-To abuse@twtelecom.net
Xref x330-a1.tempe.blueboxinc.net comp.soft-sys.math.mathematica:8023

Show key headers only | View raw


Thanks for your comments.  My followups are inlined below:

> >** Take for example the following: (Taken from the mathematica 8
> >virtual book section "Applying Functions to Lists and Other
> >Expressions")
> >geom[list_] := Apply[Times, list]^(1/Length[list])
> >So, this does a bad thing for geom[ x+ y]  (returns (Sqrt[x y])
>
> What were you expecting here? This looks correct to me


the snippet for 'geom' is taken for the mathematica tutorial, and is
meant to show the user how to define a function that implements the
geometric mean.  so for instance,
geom[{x,y,z}] = (x y z )^(1/3).  But geom[x+y] treats the expression
as a list and returns Sqrt[x y], which is not what a new user would
expect ( a better answer would be x+y)



>
> >The built-in function GeometricMean properly complains when given
> >this input,
>

I'm saying GeometricMean does not get fooled by GeometricMean[x+y],
which means the author thought of how to protect it from doing the
wrong thing -- and it would be nice to see exactly what syntax they
used.


>
> If you want to look at examples of well written Mathematica
> packages, a good place to start is to look at the packages that
> ship with Mathematica.
 Actually that's exactly what I've started to do, once I nailed down
the location of the bundled packages.  Though I've yet to find the
definition for GeometricMean in the install directory -- presumable it
is a native command.

Thanks




Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: Tips for writing correct, non trivial Mathematica Libraries Bill Rowe <readnews@sbcglobal.net> - 2012-01-19 10:17 +0000
  Re: Tips for writing correct, non trivial Mathematica Libraries "l.i.b." <nehal.alum@gmail.com> - 2012-01-20 06:47 +0000

csiph-web