Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.alt.net!nx01.iad01.newshosting.com!newshosting.com!newspump.sol.net!post2.nntp.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail From: Bob Hanlon Newsgroups: comp.soft-sys.math.mathematica Subject: Re: How to avoid repeated recalculation of the same function Date: Sat, 3 May 2014 07:40:33 +0000 (UTC) Sender: steve@smc.vnet.net Approved: Steven M. Christensen , Moderator Message-ID: References: <20140502061856.7A2216A46@smc.vnet.net> Lines: 38 Organization: Time-Warner Telecom NNTP-Posting-Date: 03 May 2014 07:46:47 GMT NNTP-Posting-Host: 34e5c530.news.twtelecom.net X-Trace: DXC=5XTl[dHb:LdnJ]SQJ40F_gC_A=>8kQj6m;[h;PUXBgbdAQ5nGY>YK1nEFiONJ7[GofUhmQ9 wrote: > Hi, > > I'm doing a calculaton that's purly symbolic (no graphing, numerical > integration, etc.). > > Suppose I have a function f[x_]:=... that's very complex to build. In > fact, f[x] ends up being a manageable expression (about 30 characters) but > it takes Mathematica about 30 min to build that expression. > > Another function g[] uses the function f[x] and references it many times. > I've discovered that g[] actually builds f[x] every time it's referenced > which takes 30 minutes each time. Theoretically, Mathematica could build it > once and then use the resulting expression every time it's referenced. > > So how do I accomplish that? That is, how do I make it build f[x] once and > then use the resulting expression when it's needed? > > Thanks, > > > Pavel > >