[Date Index]
[Thread Index]
[Author Index]
Re: A zillion times slower in version 5
*To*: mathgroup at smc.vnet.net
*Subject*: [mg46326] Re: A zillion times slower in version 5
*From*: drbob at bigfoot.com (Bobby R. Treat)
*Date*: Sat, 14 Feb 2004 04:38:03 -0500 (EST)
*References*: <c0k3sd$8kn$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
I'm not altogether sure what's going on, but I gather that most of the
variables don't matter -- their partials are miniscule -- but
Mathematica doesn't know this and spends a lot of time making sure it
doesn't lose precision.
bug[x_, {a_, b_, c_, d_}] = c + (1 - c - d)(1 - Exp[-(10^((x -
a)/20))^b]);
grad[expr_] := D[expr, #] & /@ {x, a, b, c, d}
bugGrad[x_, {a_, b_, c_, d_}] = grad@bug[x, {a, b, c, d}];
In its pure form, the gradient at your input point crashed Mathematica
on both my machines (WinXP and Mac OSX, running 5.0.1). I did a little
experimenting to simplify the form of the gradient:
bugGrad[x, {a, b, c, d}] /. {E^(-(10^((1/20)*(-a + x)))^b) -> f,
10^((1/20)*(-a + x)) -> g, 5^(-1 + (1/20)*(-a + x)) -> h,
2^(-2 + (1/20)*(-a + x)) -> i}
{b*(1 - c - d)*f*g^(-1 + b)*h*i*Log[10],
(-b)*(1 - c - d)*f*g^(-1 + b)*h*i*Log[10],
(1 - c - d)*f*g^b*Log[g], f, -1 + f}
Then I defined a gradient function that avoids duplicated effort (but
may lose precision, I admit):
buggy[x_, {a_, b_, c_, d_}] =
Module[{f = E^(-(10^((1/20)*(-a + x)))^b),
g = 10^((1/20)*(-a + x)),
h = 5^(-1 + (1/20)*(-a + x)),
i = 2^(-2 + (1/20)*(-a + x))},
N[{b*(1 - c - d)*f*g^(-1 + b)*h*i*Log[10],
(-b)*(1 - c - d)*f*g^(-1 + b)*h*i*Log[10],
(1 - c - d)*f*g^b*Log[g], f, -1 + f}]]
(Omitting N gives another expression that crashes at your input.)
Here's the resulting gradient at your input:
buggy[-8, {-60, 3.5, 0.5,
0.01}]
{
8.422939279977523406680017`\
6.854589769156088*^-546744352\
,
-8.422939279977523406680017`\
6.854589769156088*^-546744352\
,
1.2514081215966605`6.854589\
769501057*^-546744350,
3.3885496428112179`6.854589\
770191002*^-546744360, -1.}
It appears from this that bug is (virtually) a function of d alone...
particularly when d is not exact.
Bobby
"Joshua A. Solomon" <J.A.Solomon at city.ac.uk> wrote in message news:<c0k3sd$8kn$1 at smc.vnet.net>...
> In[1]:= bug[x_,{a_,b_,c_,d_}]:=c+(1-c-d)(1-Exp[-(10^((x-a)/20))^b])
>
> Using Mathematica 4...
>
> In[2]:= {$Version, $ReleaseNumber}
> Out[2]:= {4.1 for Mac OS X (November 5, 2001),5}
>
> In[3]:= Timing[bug[-8,{-60,3.5,0.5,0.01}]]
> Out[3]:= {0. Second,0.99}
>
> Using Mathematica 5...
>
> In[2]:= {$Version, $ReleaseNumber}
> Out[2]:= {5.0 for Mac OS X (June 10, 2003),0}
>
> In[3]:= Timing[bug[-8,{-60,3.5,0.5,0.01}]]
> Out[3]:= {6.21 Second,0.99}
>
> Six seconds! What is it doing? What is the best way to streamline this?
>
> js
Prev by Date:
**Re: The Scan Built-In Function**
Next by Date:
**Re: FindRoot in Version 5**
Previous by thread:
**A zillion times slower in version 5**
Next by thread:
**Re: A zillion times slower in version 5**
| |