Questions on the use of numerical functions NIntegrate and NDSolve.
21
votes
4answers
542 views
How to use NDSolve to track equilibrium?
I am looking for an extension of NDSolve where integration runs until certain variables are settled at an equilibrium. Now I have a working solution in my sleeves ...
18
votes
1answer
421 views
Publishing results obtained in Mathematica
I've been using Mathematica to solve nonlinear partial differential equations for my doctoral research for the last 2 years or so. I am not an expert in Mathematica or mathematics and I am an engineer ...
17
votes
1answer
252 views
Is there an NDSolve`ProcessEquations analog for NIntegrate?
NDSolve has an interface for repeatedly solving an equation with different initial conditions without having to analyze the equation and set up the solving algorithm each time. This can improve ...
16
votes
2answers
490 views
16
votes
2answers
356 views
3D orbits and inaccuracy over time
I wrote a little program to use Newton's Law of Universal Gravitation to animate 3 planets orbiting a central star, but I have run into a problem. Here is the code that I used to create the program (I ...
15
votes
2answers
617 views
Why does Mathematica give the wrong answer when integrating?
I integrate
Integrate[Exp[I Cos[b - c]] Cos[b], {b, 0, 2 Pi}]
Mathematica gives:
2 I Pi BesselJ[1, 1]
Which is indepedent ...
14
votes
1answer
214 views
Why does LogLinearPlot sample its argument outside the specified domain?
I experience a weird bug in the function LogLinearPlot. If the input is an interpolation function, such as the one created like this,
...
13
votes
3answers
1k views
Solving a Volterra integral equation numerically
I would like to solve for $P(t)$, in Mathematica, a Volterra integral equation of the 2nd kind.
It is:
$$P(t) = R_0(t) + \int_0^t P(t') R_0(t-t')dt'$$
I know the function $R_0$ and would ...
13
votes
1answer
262 views
Optimizing a Numerical Laplace Equation Solver
Laplace's Equation is an equation on a scalar in which, given the value of the scalar on the boundaries (the boundary conditions), one can determine the value of the scalar at any point in the region ...
12
votes
3answers
424 views
NIntegrating within an Ellipsoid
I need to numerically integrate an expensive positive-definite function over a 2D domain. I know by other ways that the function is basically zero for values outside the following ellipse:
...
12
votes
4answers
1k views
Numerical Fourier transform of a complicated function
Say I have a function $f(x)$ that is given explicitly in its functional form, and I want to find its Fourier transform[1]. If $f$ is too complicated to have an analytic expression for $\hat f(k)$, how ...
12
votes
1answer
326 views
How to guarantee that NDSolve correctly detects abrupt changes in parameters?
When using NDSolve, I often have parameters that, in most of their domain, have a constant or null variation, but that suffer from abrupt variations on a very small ...
11
votes
2answers
617 views
Nested NIntegrate
Suppose that we have the given simple integral expression
$$
\int_{-5}^{5} x \int_{-\infty}^{x} e^{\int_{0}^{z} -y dy} dz dx
$$
Writing this out in Mathematica we obtain:
...
11
votes
1answer
930 views
Parallelizing Numerical Integration in Mathematica
I have an ugly, six dimensional function that I need to integrate numerically. It works, but it currently take twelve hours to complete the calculation. Is there any good way to parallelize the ...
11
votes
1answer
262 views
Boosting the performance of expensive NIntegrate by feeding in a cheap approximation of the integrand
I need to integrate an expensive likelihood L[x] over its n-dimensional domain.
I know that L[x] is decently approximated by a ...
10
votes
1answer
213 views
Why can't I change the value of MaxRecursion in NIntegrate when integrating BesselJ?
I am trying to evaluate this integral numerically
$$
\int_0^{\infty } J_0(q R) \tanh(q) \, \mathrm{d}q
$$
for large values of $R$. This makes the integrand oscillate more quickly and Mathematica ...
9
votes
1answer
466 views
I failed to solve a set of one-dimension fluid mechanics PDEs with NDSolve
@DNA
The fluid here has been assumed as single component perfect gas i.e. it obeys the equation P=ρRT, the thermal conductivity is assumed as a constant, so the equation is:
...
9
votes
1answer
637 views
Numerically solving an inhomogeneous partial differential equation
I'm trying to solve a cylindrical partial differential equation with boundary conditions. But I got an error message saying ...
9
votes
1answer
388 views
How to tell mathematica not to resolve stiffness issues
Very often I solve partial differential equations that are nonlinear and could be up to 4th order. In these cases, it is usual for the solution determined by ...
8
votes
5answers
253 views
How do I obtain the enclosed area of this particular parametric plot?
I'm trying to find a way to obtain the enclosed area of this particular plot. Can someone show me how?
...
8
votes
4answers
223 views
Numerical integration of a numeric data available as a nested list
I have some numerical data in the form of a list with the following structure: {...{x,y,z},...} defining a surface z=z(x,y) in a 3D space (x,y,z). The data came from a simulation, and I am ...
8
votes
1answer
374 views
Is it possible to set a variable as a positive one in the whole notebook?
I'm having issues during integration due to the fact that Mathematica doesn't know if an undefined variable is positive or not (it gives me complexes which bothers me in the end).
For example I do ...
8
votes
1answer
881 views
Kramers-Kronig in Mathematica
I am trying to calculate the change of the refractive index from the change of the absorption coefficient using the Kramers-Kronig relations, in Mathematica.
...
8
votes
2answers
133 views
Problem with NIntegrate when WorkingPrecision is specified
I am trying to evaluate this integral numerically:
$$
\int_0^{\infty } m \exp (-m) J_1(m){}^2 \, dm
$$
Everything is OK when only the integration method is specified:
...
8
votes
1answer
338 views
1D Euler Equations
Is it possible to accurately solve the 1D Euler equations in Mathematica using NDSolve?
For example, let us consider the problem given here: http://www.csun.edu/~jb715473/examples/euler1d.htm
Using ...
8
votes
1answer
307 views
Animate the scattering of a Wave Packet
I know mathematica is probably not the best choice for intense numerical integration, but its the only software I know.
I would like to create an animation (not real-time, but pre-render the ...
7
votes
5answers
310 views
How to distinguish between lists and values?
I have a (hopefully small) problem with some numerical integration algorithm, more specifically I want to integrate the imaginary part of a complex valued function, e.g. ...
7
votes
2answers
273 views
Starting NDSolve from intermediate time step?
I always wondered if I could start NDSolve from an intermediate time step.
What I mean is, in the code sample below, if I were to run my solution from tmin=0 to ...
7
votes
4answers
330 views
7
votes
3answers
312 views
How to integrate functions of linearly interpolated data?
At first, consider integration of pure InterpolatingFunction.
Importing some data (works in v.9, for earlier versions one can use this link to download zipped ...
7
votes
1answer
307 views
Efficient evaluation of functions defined by NIntegrate
I have a complicated function $f$ and I want to plot the function $F(x)$ defined by the definite integral of $f$ from $0$ to $x$:
$$
F(x) = \int_0^x f(y)\mathrm dy.
$$
Apparently $f$ cannot be ...
7
votes
2answers
305 views
How to apply restrictions to the “integrated” variable, when using NDSolve?
I have to integrate an energy along a path. I know the energy at the "beginning" of the path (energy[0]), and I can determine the energy change (gain and loss) ...
7
votes
1answer
229 views
Setting the DifferenceOrder Option
I've been playing around with Method in NDSolve[...] and can't quite seem to figure out how to force ...
7
votes
1answer
186 views
What does MaxStepFraction do?
I find that with NDSolve[...] while solving a partial differential equation, changing the MaxStepFraction from ...
7
votes
1answer
142 views
The only usage for the option InterpolationOrder in NDSolve is to be set to All?
We know that changing the option InterpolationOrder in ListLinePlot、ListPlot3D、...
7
votes
0answers
130 views
Numerically solve 2nd order differential equation with singularity
Consider a second order differential equation with a potential that diverges at some generic value in the variable. For example:
$$-y^{\prime\prime}(s)+\frac1{\mathrm{cn}{(s\mid k^2)}}y(s)=0$$
where ...
7
votes
0answers
1k views
Integro-differential equation
I have to numerically solve a nonlinear partial integro-differential equation using Mathematica. This is my equation,
$$\frac{\partial y(x,t)}{\partial t}=\int_{-\infty}^\infty K_0(|x-u|) ...
6
votes
2answers
234 views
How to work out the parameter in a definite integration which has an exact value while the integration doesn't have an analytical solution?
Here is the equation I'm trying to solve:
NIntegrate[1/(E^(1/(λ T)) - 1), {λ, 200, 220}] == 1000
T is the parameter I'm ...
6
votes
3answers
360 views
Strategies to solve an oscillatory integrand only known numerically
I have an integrand that looks like this:
the details of computation are complicated but I only know the integrand numerically (I use NDSolve to solve second ...
6
votes
2answers
151 views
Catching only the first event in NDSolve EventLocator
I have a system of ODEs that I solve. During the integration process, there's an event that I want to catch, but I want to (a) continue the integration after the event and (b) catch only the first ...
6
votes
2answers
597 views
Convolution with interpolated function
I have some problems to calculate in reasonable speed the convolution of an interpolated function with a Gauss function.
I have here (ExampleData.txt, alternate Pastebin link) data which I ...
6
votes
2answers
161 views
How to deal with zero in NDSolve in mathematica?
I would like to solve the following ODEs
$$\begin{cases} x'(t)&=y\\
y'(t)&=-y(t)/t-e^{x(t)},\\
x(0)&=1,\\y(0)&=0,
\end{cases}$$
(EDIT :
The second equation used to be $y'(t) = ...
6
votes
2answers
421 views
How to set the NDSolve method to LSODA
I notice that off all the Method options available for NDSolve[...], LSODA is invoked quite ...
6
votes
1answer
210 views
NDSolve and WhenEvent Causing Excess Work
When I use the following system
model = {x'[t] == x[t] (1 - x[t]) - x[t] y[t], y'[t] == x[t] y[t] - y[t], x[0] == 0.5, y[0] == 0.5}
with the ...
6
votes
1answer
270 views
Speeding up numerical Fourier Transform
I wrote this function NFourierTransform, which takes a function $f(k)$ and numerically calculates the fourier transform integral for discrete values of $k \in ...
6
votes
2answers
137 views
6
votes
1answer
208 views
Getting Integrate to perform numerical integration
I am trying to calculate the mutual impedance of two antennas which is just a big integral. I defined my function in terms of my variable, but when I execute it, Mathematica runs for a while and then ...
6
votes
1answer
60 views
6
votes
0answers
63 views
Modify NDSolve`StateData (if possible)
I am trying to solve a PDE that needs to be scaled constantly (refer to this). @andre suggests I modify NDSolve`StateData.
Now, the problem is, I'm not used to ...
6
votes
0answers
217 views
Optimizing NIntegrate for higher PrecisionGoal
By default, NIntegrate works with MachinePrecision and its PrecisionGoal is set to ...
