MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Tips for writing correct, non trivial Mathematica Libraries

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124484] Re: Tips for writing correct, non trivial Mathematica Libraries
  • From: Richard Fateman <fateman at cs.berkeley.edu>
  • Date: Sat, 21 Jan 2012 05:16:37 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jf68se$g99$1@smc.vnet.net>

On 1/18/2012 3:02 AM, l.i.b. wrote:
....
>
> At the same time, clearly there are large Mathematica projects out
> there (e.g. Wolfram|Alpha), so there must be a way to do this
> efficiently, I'm just not seeing it.  I'm looking for comments and/or
> advise regarding my point of view.

Large parts of Mathematica (and presumably Alpha) are not written in
the Mathematica language and therefore do not suffer from design
issues of that language.  They suffer from the design issues of other
languages like C, C++, Java,  whatever.

As Andrzej pointed out, you can do a kind of type checking by looking
at the Heads of arguments. This may remedy some of the problems you
anticipate.

Using Mathematica generally involves a leap of faith that any of the
routines that you are using continue to do the same thing as when you
tested them, and that they have not been "improved" so as to fail
in your particular context.

It is a common approach in computer algebra system design that if you 
have a program f(x) that computes something if x is of a special type, 
then if x is NOT of that type, "f(x)"  is returned.  That is, if an 
integral cannot be resolved to an integral-free expression, it is 
returned with an integral in it.

Consequently, most programs that one would expect to operate on (say) 
numbers, must also do something reasonable if the arguments are somehow 
unresolved symbolic expressions.

A good library will therefore respond politely to strange inputs.

There are ways of specifying how N  should work on your functions, if 
that is your main concern.  NHoldAll, NumericFunction, and I suppose you
can define N[X_YourFunction,d_digits]  to define number evaluation strategy.

RJF

>
>
>
>




  • Prev by Date: Re: Tips for writing correct, non trivial Mathematica Libraries
  • Next by Date: Re: Derivatives Output as TraditionalForm
  • Previous by thread: Re: Tips for writing correct, non trivial Mathematica Libraries
  • Next by thread: Re: Tips for writing correct, non trivial Mathematica Libraries