| Author |
Comment/Response |
phsopher
|
04/13/12 06:07am
I'm fairly new to Mathematica and I was wondering if it is possible to save your own functions somehow so they don't need to be evaluated every time. For example, I have a function of p which involves an integral
Int[p_] := Integrate[Sqrt[p^2 a[x]^(-2) + a[x]^(-3) Sin[x]^2], {x, 0, Pi/2}]
The function a[x] is defined as
a[x_] := (1 + 3/8 x)^(2/3)
Now if I want for instance to plot Int[p] it takes absolute ages and I would like to somehow save the values of the function so that once it's been calculated I could use it in other calculations.
For example, if I set a[x] to be constant then the integral can be reduced to the complete elliptic integral of the second kind for which Mathematica has an inbuilt function EllipticE[n]. Using the inbuilt function is orders of magnitude faster than calculating the integral. I don't really know how the unbuilt functions work, but what I'm asking is whether it would be possible for me to build a funcion like EllipticE[n] only now with a[x] in the integral as above.
URL: , |
|