# Tagged Questions

Questions on the use of numerical functions NIntegrate and NDSolve.

2k views

### When I can 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-...
3k 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. ...
484 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 ...
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 ...
5k 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: ...
743 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 ...
2k 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 <...
1k 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: ...
1k 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 problem given here: http://www.csun.edu/~...
414 views

### Is there an NDSolveProcessEquations 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 ...
2k 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?
2k 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 (...
1k 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 ...
4k 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$$ ...
2k 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 ...
928 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 ...
2k 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: ...
6k 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 ...
4k 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 ...
508 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 ...
527 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$$ ...
412 views

6k 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 ...
611 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 ...
503 views

### Gillespie Stochastic Simulation Algorithm

The Gillespie SSA is a Monte Carlo stochastic simulation algorithm to find the trajectory a dynamic system described by a reaction (or interaction) network, e.g. chemical reactions or ecological ...
446 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. ...
3k views

### What method does NDSolve use for solving PDEs?

What is NDSolve's mode of operation? I use it to solve partial differential equations and never gave it too much thought. Recently, I came across this question. ...
324 views

### What can one do with extremely stiff problem in NDSolve?

Consider the following illustrative problem: $$\frac {\partial f} {\partial t} = \frac {\partial} {\partial x}(x f) + \frac {\partial} {\partial x}(f \frac {\partial f} {\partial x})$$ This is ...
311 views

### Inconsistent behavior of WhenEvent[ ]

Consider the following simple example: ...
1k views

### Plot Matlab icon

I started to explore this on a whim and hasn't succeeded yet… Some introduction for the icon is found here but I can't understand it very well. (I admit that, though playing with ...
903 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: ...
1k views

### NIntegrate error bound

I am trying to evaluate a highly oscillatory integral using NIntegrate. I fear that due to limited resources (time and/or memory), I will not be able to evaluate the integral to the desired precision. ...
407 views

### WhenEvent and partial derivatives

Can WhenEvent be used to reset the conditions on a PDE at a given time? How would the syntax of that be? This is the code Im using ...
2k 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. ...
116 views

### Empty WhenEvent action crashes kernel

Bug introduced in 9.0 and persisting through 10.4.1 WhenEvent is new in 9.0. This is an example from the docs, slightly modified (action is wrapped in ...
6k 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 ...
I'm trying to simulate a particle in an electric and magnetic fields, but numerically instead of analytically. This is basically solving the equation q \cdot \left(p'\times B\right) + q\cdot E = m ...