Questions tagged [numerical-integration]

Questions on the use of numerical functions NIntegrate and NDSolve.

Filter by
Sorted by
Tagged with
68 votes
4 answers
3k views

When can I assume that all decimal digits returned by Mathematica are provably correct?

How to Control the Precision and Accuracy of Numerical Results Arbitrary-Precision Numbers Mathematica works with exact numbers and with two different types of approximate numbers: machine-...
user avatar
43 votes
2 answers
13k 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: ...
user avatar
  • 6,350
39 votes
2 answers
6k views

Complex valued 2+1D PDE Schrödinger equation, numerical method for `NDSolve`?

Based on the heat equation of the Mathematica Manual tutorial, I wrote the complex counterpart (Schrödinger) equation, for the free particle propagation of an initial wavepacket. ...
user avatar
  • 847
39 votes
2 answers
2k views

How to implement custom integration rules for use by NIntegrate?

How can NIntegrate be extended with custom implementation of integration rules? This answer of the question "Monte Carlo integration with random numbers generated ...
user avatar
36 votes
2 answers
5k views

Determining which rule NIntegrate selects automatically

I need to numerically integrate a highly oscillatory function over the semi-infinite domain $(0,\infty)$: $$\int_0^\infty \frac{\sin^2(x) \sin^2(1000 x)}{x^{5/2}}\mathrm dx$$ Since the Levin rule (...
user avatar
  • 361
35 votes
1 answer
7k views

Numerical integration --- Mathematica vs Python (w/ Scipy) performance

I'm about to tackle a problem that involves a lot of (multi-dimensional) numerical integrations and also subsequent optimizations, and so I want to make sure at least the integration step is as fast ...
user avatar
  • 1,163
32 votes
4 answers
2k 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 ...
user avatar
31 votes
3 answers
5k views

Numerical solution of coupled ODEs with boundary conditions

I have to solve the following set of ODEs and just can't get good results using Mathematica $$ r\frac{d}{dr}\left(\frac{1}{r}\frac{d}{dr}A(r)\right)-\xi^2F(r)^2\left(A(r)-1\right)=0 $$ $$ \frac{1}{r}\...
user avatar
  • 941
30 votes
3 answers
3k views

1D Euler equations (fluid dynamics) with NDSolve

Is it possible to accurately solve the 1D Euler equations in Mathematica using NDSolve? For example, let us consider the Sod shock tube problem. Introduction to ...
user avatar
29 votes
3 answers
5k views

Programming a numerical method in the functional style

I am new to Mathematica and I would like to learn a bit more about functional programming. At the moment I have assignments like programming different numerical methods (for integration: ...
user avatar
  • 393
29 votes
1 answer
947 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 ...
user avatar
  • 5,171
28 votes
1 answer
3k views

Gillespie Stochastic Simulation Algorithm

The Gillespie SSA is a Monte Carlo stochastic simulation algorithm to find the trajectory of a dynamic system described by a reaction (or interaction) network, e.g. chemical reactions or ecological ...
user avatar
27 votes
1 answer
7k views

How to solve a non-linear integral equation?

I have a non-linear integral equation that I'd like to solve with Mathematica: $$ \int_{0}^{1} \mathrm{d}x \frac{B(x) v}{(B(x) + B(v))^2} = 1$$ ...
user avatar
25 votes
3 answers
7k 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 ...
user avatar
  • 2,745
25 votes
2 answers
2k 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 ...
user avatar
25 votes
2 answers
3k views

Using a compiled function inside NIntegrate gives "CompiledFunction::cfsa" message

The following function is defined for Real input: ...
user avatar
  • 1,547
24 votes
5 answers
12k 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 ...
user avatar
  • 6,976
24 votes
3 answers
924 views

Is there any possibility to implement a structure like a ProgressIndicator into NDSolve?

It is already formulated in the title. NDSolve takes sometimes a considerable piece of time. It would be very practical to have some information on how long it is still to wait. So, any ideas? To ...
user avatar
24 votes
2 answers
3k views

I failed to solve a set of one-dimension fluid mechanics PDEs with NDSolve

The fluid here has been assumed as single component perfect gas i.e. it obeys the equation $p=ρ R T$, the thermal conductivity is assumed as a constant, so the equation set is: ...
user avatar
  • 54.2k
24 votes
4 answers
5k 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 <...
user avatar
24 votes
2 answers
3k 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 ...
user avatar
24 votes
2 answers
2k views

Easy way to plot ODE solutions from NDSolve?

Inspired by the closed question Beautify a NDSolve Graph ! and a comment someone made to me not too long ago: Is there some quick way to plot NDSolve results ...
user avatar
  • 220k
24 votes
1 answer
778 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 ...
user avatar
  • 4,941
23 votes
1 answer
1k views

Implement fractional Laplacian

What is a way to implement the Fractional Laplacian with Mathematica? How can we apply such implementation to numerically solve the problem $$(-\Delta)^su = 1 \text{ in } B_1(0), \\ u = 0 \text{ in ...
user avatar
23 votes
2 answers
5k views

Plotting separatrices for nonlinear system

Consider the system: \begin{align*} x'&=(1-x-y)x\\ y'&=(4-7x-3y)y \end{align*} The system has a saddle point at (1/4,3/4). How can I plot the separatrices on the phase portrait having domain ...
user avatar
  • 14.6k
23 votes
1 answer
1k views

Numerical inverse Laplace-Hankel transform

When trying to reproduce the result of this paper about numerical solution of Lamb's problem, I encountered the following double integral (to be more precise, the 0-order inverse Hankel-Laplace ...
user avatar
  • 54.2k
22 votes
5 answers
5k views

How to speed up the plot of NIntegrate?

Here is a toy example: f[t_] := NIntegrate[Sin[x], {x, 0, t}]; Plot[f[t], {t, 0, 10}] // Timing Even such a simple example will take 2.8 seconds on my computer. ...
user avatar
  • 2,712
22 votes
4 answers
2k views

Only final result from NDSolve

Finally, I started to play with differential equations in Mathematica. And I have faced the problem, which seems to me so basic that I'm afraid this question is going to be closed soon. However, I'...
user avatar
  • 133k
22 votes
4 answers
4k views

How to calculate the volume of a convex hull?

Given a spatial curve represented by a parametric equation, is it possible in Mathematica 9 to calculate symbolically (or at least numerically) the volume of its convex hull?
user avatar
  • 437
22 votes
2 answers
1k views

NDSolve uses different difference order for different spatial derivative when solving PDE

I found something this tutorial for method of line doesn't tell us. Consider the following toy example: ...
user avatar
  • 54.2k
21 votes
3 answers
677 views

More efficient method to compute moments of the Johnson $S_B$ distribution

Here is a very specific feature request. I need Mean[JohnsonDistribution["SB", γ, δ, 0, 1]] When I issue e.g. ...
user avatar
21 votes
2 answers
2k views

Least effort to handle a point source inside the domain of PDE(s)

By point source I mean a constrained condition at one point inside the domain of PDE(s). For example: $$\frac{\partial ^2u(t,x,y)}{\partial t^2}=\frac{\partial ^2u(t,x,y)}{\partial x^2}+\frac{\...
user avatar
  • 54.2k
21 votes
2 answers
2k views

Why does Mathematica give the wrong answer when integrating?

Bug introduced in 8.0 or earlier and fixed in 9.0.0 I integrate Integrate[Exp[I Cos[b - c]] Cos[b], {b, 0, 2 Pi}] Mathematica gives: ...
user avatar
  • 973
21 votes
1 answer
459 views

How to implement custom NIntegrate integration strategies?

How can new integration strategies algorithms be used with NIntegrate? This is a different type of extension than the extensions with new integration rules, as ...
user avatar
21 votes
1 answer
2k views

How do I create a triangulated surface from points?

I have a set of points in a nx3 matrix and I would like to convert them into a surface, so that I may calculate its surface area. The function ListSurfacePlot3D creates the surface how I want it. ...
user avatar
  • 215
20 votes
4 answers
7k views

Finding the volume of a sphere using the Monte Carlo algorithm

I used the following code to find the volume of the sphere $x^2+y^2+z^2 \leq 1$ in the first octant: ...
user avatar
  • 355
20 votes
3 answers
17k views

NDSolve with Euler method

I want to solve this equation with NDSolve[] using the Euler method: x'[t] == 0.5*x[t]-0.04*(x[t])^2 with initial condition ...
user avatar
  • 1,163
20 votes
3 answers
2k views

Numerically solve the initial value problem for the 1-D wave equation

I want to solve the standard 1-dimensional wave equation $y_{xx}=y_{tt}$ using NDSolve (for $y(x,t)$) with the following conditions: ...
user avatar
  • 313
19 votes
4 answers
1k views

A bug in Integrate

Integrate[(1 + 16 Tan[2 x - y]^2)/(1 + 4 Tan[2 x - y]^2), {x, 0, 2 π}] Mathematica (wrong) output is (tested under versions 8 and 10.0, took ~ 1 minute of CPU ...
user avatar
18 votes
6 answers
3k 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? ...
user avatar
18 votes
3 answers
11k views

Solving a time-dependent Schrödinger equation

I want to solve the time-dependent Schrödinger equation: $$ i\partial_t \psi(t) = H(t)\psi(t)$$ for matrix, time-dependent $H(t)$ and vector $\psi$. What is an efficient way of doing this so that ...
user avatar
18 votes
5 answers
3k views

periodic boundary conditions and NDEigensystem

Mathematica 10 has a splendid new function, NDEigensystem, that makes it possible to solve Sturm-Liouville problems numerically in a single step. I have not however been able to find a way to get it ...
user avatar
  • 1,302
18 votes
3 answers
6k views

Is it possible to calculate a Lebesgue integral in Mathematica?

As the title says, I wonder if it is possible to calculate a Lebesgue integral in Mathematica, especially when the domain of integration is $\mathbb{R}^N$, or in other words multivatiate Lebesgue ...
user avatar
18 votes
2 answers
3k views

Solve differential equation using a integral form boundary condition

I have a second order differential equation and I want to solve it analytically (DSolve) and numerically (NDSolve) with ...
user avatar
  • 327
18 votes
3 answers
3k views

What is NDSolve`FEM`*?

I stumbled on this: ?"NDSolve`FEM`*" ...
user avatar
  • 4,941
18 votes
1 answer
683 views

Inconsistent behavior of WhenEvent[ ]

Consider the following simple example: ...
user avatar
18 votes
2 answers
1k views

What boundary is added when boundary condition is not sufficient?

When insufficient boundary conditions are given to NDSolve for solving PDE, usually the warning NDSolve::bcart pops up: ...
user avatar
  • 54.2k
17 votes
5 answers
869 views

Mismatch between numerical and analytic evaluation of an integral

I evaluated the following integral $$\int_0^1 \sqrt{r} \left | \cos \left(\left(k+\frac{1}{2}\right) \pi r\right)\right | dr$$ ...
user avatar
17 votes
2 answers
4k views

What's behind Method -> {"EquationSimplification" -> "Residual"}

In order to solve a quite large system of differential equations, I have the habit to use the NDSolve command without changing any options. As I wanted more ...
user avatar
  • 890
17 votes
4 answers
933 views

Piecewise imposes internal boundaries in NDSolve - is this expected?

In the following code I used True as the predicate for DirichletCondition and found that the boundary condition was applied not ...
user avatar
  • 83.6k

1
2 3 4 5
63