# Solving an Integral Numerically

I have been trying to solve the integral equation below, but cant seem to find a way out of this. Can someone please help me out with suggestion?

$f(t)=\int_0^{\infty}\frac{K_1a(t)}{a(t)+K_2}\,dt$

where $K_1$ and $K_2$ are some constants and $a(t) = \frac{Q}{(4\pi Nt)^{3/2}}*\exp(-x^2/(4Nt))$.

Thank you so much

Replay

Just some points:

1. $a$ is a function of $x$ and $t$. Hence $f$ as defined will be a function of $x$.,ie. $f(x)=\int_0^\infty g(x,t)\, dt$ where $g(x,t)$ is your integrand.
2. To numerically integrate (as question title asks &given function of Gaussian's[diffusion eqn soln]), $f(x)$ needs a numerical argument.
3. I am not sure what your ultimate aim is.

a[x_, t_, q_, n_] := q Exp[-x^2/(4 n t)]/(4 Pi n t)^(3/2);
f[x_, q_, n_, k1_, k2_] :=
k1 NIntegrate[a[x, t, q, n]/(k2 + a[x, t, q, n]), {t, 0, Infinity}]

Applying, e.g. visualingf:

Plot[f[x, 1, 1, 1, 1], {x, -1, 1}]

This may take variable time depending on arguments. I hope this facilitates your aims.

I tried a few random values for constants and it worked for me. Here are some things you might be doing wrong:

• Using N as a variable: N is a protected symbol. Use n
• Using Integrate instead of NIntegrate when you want a numerical answer
• Defining the integral as a function: You are using $t$ as the integration variable, not as a function parameter.

Does this help, first you replace your equation as,

Simplify[(k1*a[t])/(a[t] + k2) dt /. a[t] -> (Q/(4*Pi*N*t)^(3/2))*exp (-x^2/(4*N*t))]

(dt exp k1 Q x^2)/(-32 k2 [Pi]^(3/2) (N t)^(5/2) + exp Q x^2)

Now apply integral,

Integrate[ Simplify[-((dt exp k1 Q x^2)/(32 N \[Pi]^(3/2) t (N t)^(
3/2) (k2 - (exp Q x^2)/(32 N \[Pi]^(3/2) t (N t)^(3/2)))))], t]

$\frac{\text{dt} \exp ^{2/5} \text{k1} Q^{2/5} x^{4/5} \left(-\sqrt{5} \log \left(\exp ^{2/5} Q^{2/5} x^{4/5}+\left(1+\sqrt{5}\right) \pi ^{3/10} \sqrt[5]{\exp } \sqrt[5]{\text{k2}} \sqrt{N} \sqrt[5]{Q} \sqrt{t} x^{2/5}+4 \pi ^{3/5} \text{k2}^{2/5} N t\right)+\log \left(\exp ^{2/5} Q^{2/5} x^{4/5}+\left(1+\sqrt{5}\right) \pi ^{3/10} \sqrt[5]{\exp } \sqrt[5]{\text{k2}} \sqrt{N} \sqrt[5]{Q} \sqrt{t} x^{2/5}+4 \pi ^{3/5} \text{k2}^{2/5} N t\right)+\sqrt{5} \log \left(\exp ^{2/5} Q^{2/5} x^{4/5}-\left(\sqrt{5}-1\right) \pi ^{3/10} \sqrt[5]{\exp } \sqrt[5]{\text{k2}} \sqrt{N} \sqrt[5]{Q} \sqrt{t} x^{2/5}+4 \pi ^{3/5} \text{k2}^{2/5} N t\right)+\log \left(\exp ^{2/5} Q^{2/5} x^{4/5}-\left(\sqrt{5}-1\right) \pi ^{3/10} \sqrt[5]{\exp } \sqrt[5]{\text{k2}} \sqrt{N} \sqrt[5]{Q} \sqrt{t} x^{2/5}+4 \pi ^{3/5} \text{k2}^{2/5} N t\right)-4 \log \left(\sqrt[5]{\exp } \sqrt[5]{Q} x^{2/5}-2 \pi ^{3/10} \sqrt[5]{\text{k2}} \sqrt{N} \sqrt{t}\right)+2 \sqrt{10-2 \sqrt{5}} \tan ^{-1}\left(\frac{8 \pi ^{3/10} \sqrt[5]{\text{k2}} \sqrt{N} \sqrt{t}-\left(\sqrt{5}-1\right) \sqrt[5]{\exp } \sqrt[5]{Q} x^{2/5}}{\sqrt{2 \left(5+\sqrt{5}\right)} \sqrt[5]{\exp } \sqrt[5]{Q} x^{2/5}}\right)-2 \sqrt{2 \left(5+\sqrt{5}\right)} \tan ^{-1}\left(\frac{\left(1+\sqrt{5}\right) \sqrt[5]{\exp } \sqrt[5]{Q} x^{2/5}+8 \pi ^{3/10} \sqrt[5]{\text{k2}} \sqrt{N} \sqrt{t}}{\sqrt{10-2 \sqrt{5}} \sqrt[5]{\exp } \sqrt[5]{Q} x^{2/5}}\right)\right)}{40 \pi ^{3/5} \text{k2}^{2/5} N}$

Category: numerical integration Time: 2014-02-23 Views: 1