Here we will use a trickof using Evaluate[] in a function definition to save time--a small diversion here will demonstrate why this is efficient

In[11]:=

Timing [ f [ c_ ] := Evaluate [ Integrate [ Exp [ Tan [ x ] ] , { x , 0 , c } ] ] ]

Out[11]=

{ 7.776986999999998 Second , Null }

In[12]:=

Timing [ g [ c_ ] := Integrate [ Exp [ Tan [ x ] ] , { x , 0 , c } ] ]

Out[12]=

{ 0.000032999999998395424 Second , Null }

In[13]:=

? f

Global`f

f [ c_ ] := c If [ - π 2 Re [ c ] π 2 || Im [ c ] 0 , - ( - ExpIntegralEi [ ] + 2 ( ExpIntegralEi [ - ] - ExpIntegralEi [ - + Tan [ c ] ] ) + ExpIntegralEi [ + Tan [ c ] ] ) 2 c , Integrate [ Tan [ c x ] , { x , 0 , 1 } , Assumptions ! ( - π 2 Re [ c ] π 2 || Im [ c ] 0 ) ] ]

In[14]:=

? g

Global`g

g [ c_ ] := 0 c Tan [ x ] x

In[15]:=

Timing [ f [ 0.5 ] ]

Out[15]=

{ 0.0009340000000008786 Second , 0.6572099322091018 + 5.551115123125783 × 10 - 17 }

In[16]:=

Timing [ g [ 0.5 ] ]

Out[16]=

{ 0.12612800000000135 Second , 0.6572099313456736 + 5.551115123125783 × 10 - 17 }


Created by Mathematica  (October 31, 2005) Valid XHTML 1.1!