Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Saving functions' topicStudent Support Forum > General > "Saving functions"

Next Comment >Help | Reply To Topic
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: ,

Subject (listing for 'Saving functions')
Author Date Posted
Saving functions phsopher 04/13/12 06:07am
Re: Saving functions Peter Pein 04/17/12 04:53am
Next Comment >Help | Reply To Topic