Groups | Search | Server Info | Login | Register
Groups > comp.soft-sys.math.mathematica > #16895
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newspeer1.nac.net!newspump.sol.net!post2.nntp.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail |
|---|---|
| From | Alex Krasnov <akrasnov@cory.eecs.berkeley.edu> |
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: How to avoid repeated recalculation of the same |
| Date | Sat, 3 May 2014 07:41:54 +0000 (UTC) |
| Sender | steve@smc.vnet.net |
| Approved | Steven M. Christensen <steve@smc.vnet.net>, Moderator |
| Message-ID | <lk26k2$131$1@smc.vnet.net> (permalink) |
| References | <20140502061856.7A2216A46@smc.vnet.net> |
| Lines | 25 |
| Organization | Time-Warner Telecom |
| NNTP-Posting-Date | 03 May 2014 07:48:09 GMT |
| NNTP-Posting-Host | 34e5c530.news.twtelecom.net |
| X-Trace | DXC=5XTl[dHb:LDP;Ll>D9?]MBC_A=>8kQj6M;[h;PUXBgbD`9@n`L<iRVLEFiONJ7[GoFma7bhXI8nPN |
| X-Complaints-To | abuse@twtelecom.net |
| Xref | csiph.com comp.soft-sys.math.mathematica:16895 |
Show key headers only | View raw
Mathematica makes memoization easy. You can store the result directly in the function definition using the idiom f[x_] := f[x] = (...). You can then examine the stored results using Information[f]. Alex On Fri, 2 May 2014, pgeipi10@gmail.com 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 >
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar
Re: How to avoid repeated recalculation of the same Alex Krasnov <akrasnov@cory.eecs.berkeley.edu> - 2014-05-03 07:41 +0000
csiph-web