From: Jim Rockford on 8 Apr 2010 08:01 I have a certain integral, part of a larger expression, that can be expressed in terms of incomplete gamma functions by Mathematica. But in carrying out the definite integral and forcing it to be written in terms of gamma functions, this introduces branch points and other unnecessary complications. I want the integral left alone and evaluated numerically, but I still want to express the general formula for this large expression with the unevaluated integral in place. For example, I'd like f[x_] = (stuff) + int_{0}^{1} (g[s,x]) ds where the definite integral is expressed in the usual Mathematica notation. What I do *not* want Mathematica to do at this stage is to do the integral analytically and write it in terms of special functions. Instead, I just want to later make a list of values for f[x] and have the integral done numerically. How can I program this? Thanks, Jim
From: David Park on 9 Apr 2010 03:34 You could use something like the following: f[x_] := x + HoldForm[Integrate[Sin[s + x], {s, 0, 1}]] f[.5] % /. Integrate -> NIntegrate // ReleaseHold The Presentations package has a Student's Integral section that allows one to hold integrals and manipulate them, using various integration techniques, before evaluation. One uses integrate with a small "i" and then later specifies the type of integration. f[x_] := x + integrate[Sin[s + x], {s, 0, 1}] f[.5] % // UseNIntegrate giving the same answers as above. David Park djmpark(a)comcast.net http://home.comcast.net/~djmpark/ From: Jim Rockford [mailto:jim.rockford1(a)gmail.com] I have a certain integral, part of a larger expression, that can be expressed in terms of incomplete gamma functions by Mathematica. But in carrying out the definite integral and forcing it to be written in terms of gamma functions, this introduces branch points and other unnecessary complications. I want the integral left alone and evaluated numerically, but I still want to express the general formula for this large expression with the unevaluated integral in place. For example, I'd like f[x_] = (stuff) + int_{0}^{1} (g[s,x]) ds where the definite integral is expressed in the usual Mathematica notation. What I do *not* want Mathematica to do at this stage is to do the integral analytically and write it in terms of special functions. Instead, I just want to later make a list of values for f[x] and have the integral done numerically. How can I program this? Thanks, Jim
From: gekko on 10 Apr 2010 06:51 On Apr 8, 10:01 pm, Jim Rockford <jim.rockfo...(a)gmail.com> wrote: > I have a certain integral, part of a larger expression, that can be > expressed in terms of incomplete gamma functions by Mathematica. But > in carrying out the definite integral and forcing it to be written in > terms of gamma functions, this introduces branch points and other > unnecessary complications. I want the integral left alone and > evaluated numerically, but I still want to express the general formula > for this large expression with the unevaluated integral in place. > > For example, I'd like > > f[x_] = (stuff) + int_{0}^{1} (g[s,x]) ds > > where the definite integral is expressed in the usual Mathematica > notation. > > What I do *not* want Mathematica to do at this stage is to do the > integral analytically and write it in terms of special functions. > Instead, I just want to later make a list of values for f[x] and > have the integral done numerically. > > How can I program this? > > Thanks, > Jim You'll probably get at least a half-dozen replies along these lines, but just in case: one way to achieve what you want would be to make the definition of "f" only match numerical values, e.g. f[x_?NumericQ] := stuff[x] + Integrate[g[s,x], {s,0,1}] If it should only match for Integer arguments, you could use f[x_Integer] := ... instead. Cheers, P.
|
Pages: 1 Prev: Graph Theory - Pathset and Cutset determination Next: Mathematica Cluster Integration + SGE |