Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1994
*January
*February
*March
*April
*May
*June
*July
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1994

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

Search the Archive

Re: help

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: help
  • From: keiper (Jerry Keiper)
  • Date: Mon, 20 Jun 1994 13:50:56 -0500

 	> My question is the following.
	> Should I choose this way:
	> 
	>          function[x_Real,y_Real]:=
	>            N[
	>            Module[{z,t,aa,bb,cc,...},
	>            aa=2*Pi*x-y*3.12;
	>            bb=x-y;
	>            ...
	>            ]
	>            ]
	> 
	> or is it better this other one:
	> 
	>          function[x_Real,y_Real]:=
	>            Module[{z,t,aa,bb,cc,...},
	>            aa=N[  2*Pi*x-y*3.12  ];
	>            bb=N[  x-y  ];
	>            ...
	>            ]
	> 
	> Or maybe anyother thing?. Here my main interest is the 
	> computation speed.

It depends on what thos calculations are.  Clearly 

	N[Pi - Pi + 1, 10000]

will be much faster than

	N[Pi, 10000] - N[Pi, 10000] + 1

On the other hand, intermediate symbolic growth can become so large
that using N[ ] first is much better:

In[5]:= $RecursionLimit = Infinity

Out[5]= Infinity

In[6]:= N[Nest[Sin, 1, 1000]] // Timing

Out[6]= {6.35 Second, 0.054593}

In[7]:= Nest[Sin, 1., 1000] // Timing

Out[7]= {0.166667 Second, 0.054593}


Jerry B. Keiper
keiper at wri.com
Wolfram Research, Inc.





  • Prev by Date: Re: Mathematica licensing
  • Next by Date: Defining a predicate
  • Previous by thread: help
  • Next by thread: Problem with a list member?