67 votes

Test a wooden board's vibration mode

The only reason I am attempting to answer this is to perhaps get a Reversal badge. There you go... We will go slowly and this answer is the basis for what comes next. Let's start with two dimensions. ...
user avatar
  • 36.1k
59 votes
Accepted

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

General comments First, if you plan to use multi-dimensional integrals it is better to test with multi-dimensional integrals not with one dimensional ones. One might think that the test in the ...
user avatar
39 votes

Determining which rule NIntegrate selects automatically

This question comes up often enough. See this discussion at community.wolfram.com : Integration method used in NIntegrate , and the notebook Finding the applied NIntegrate methods attached to my ...
user avatar
38 votes
Accepted

Gillespie Stochastic Simulation Algorithm

Yes you can. Below is a fairly general, Mathematica-compiled, fast and robust version. Examples 1. Michaelis-Menten kinetics Michaelis-Menten kinetics for enzyme-directed substrate conversion. The ...
user avatar
37 votes
Accepted

How to implement custom integration rules for use by NIntegrate?

The simplest way to make new NIntegrate algorithms is by user defined integration rules. Below are given examples using a simple rule (the Simpson rule) and how <...
user avatar
36 votes
Accepted

Implement fractional Laplacian

I can provide an approach by finite elements and an application of the functional calculus of selfadjoint operators. Background The spectrum of the Laplacian on a bounded domain $\varOmega$ with ...
user avatar
27 votes

Nonlinear differential equation: numerical solution

Introduction I think there are several questions on this site about ODEs of the form $$(x-a)^2 u''(x) = F(x,u,u')$$ with an initial condition at $x=a$. There is no general guarantee that solutions ...
user avatar
  • 217k
26 votes

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

...
user avatar
  • 8,487
26 votes
Accepted

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

This post contains several code blocks, you can copy them easily with the help of importCode. As mentioned in the comment above, the answer is hidden in this ...
user avatar
  • 52.8k
25 votes
Accepted

Easy way to plot ODE solutions from NDSolve?

I wanted to share some undocumented techniques that give quick rough plots of NDSolve solutions. The keys points are this, the second one being quite handy at ...
user avatar
  • 217k
23 votes
Accepted

How do I create a triangulated surface from points?

It turns out ListSurfacePlot3D does a terribly poor job of approximating the surface in the OP, otherwise one will just apply ...
user avatar
  • 32.5k
23 votes
Accepted

How to implement custom NIntegrate integration strategies?

Motivation (for a new semi-symbolic integration strategy) Consider the following integral, which cannot be done neigther by Integrate: ...
user avatar
23 votes
Accepted

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

I've waited for this question for a long time :) Fully NDSolve-based Numerical Solution There actually exist 2 issues here: NDSolve can't handle unsmooth i.c. ...
user avatar
  • 52.8k
23 votes
Accepted

Can Mathematica calculate this elliptic, triple integral?

Doing the Integrals separately for a, b and c gives the answer $\frac{128}{45 \pi}\sim 0.905415$, which agrees with the numerical estimate from NIntegrate: ...
user avatar
  • 974
22 votes
Accepted

Plotting a Bifurcation diagram

An alternative representation is ...
user avatar
  • 58.4k
22 votes

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

I'll preface this answer first with a complaint: NExpectation[] and NProbability[] are not sufficiently resilient obviously ...
user avatar
22 votes
Accepted

Interpreting Mathematica code on black holes

I managed to debug the code from KerrOrbitGRProject and reproduce the results for the Schwarzschild metric (figures on pp. 7-8) ...
user avatar
  • 34.1k
21 votes

Boundary condition with spatial derivative is ignored by NDSolve

Short Answer Set Method -> {"MethodOfLines", "DifferentiateBoundaryConditions" -> {True, "ScaleFactor" -> 1}} inside ...
user avatar
  • 52.8k
20 votes
Accepted

1D Euler equations (fluid dynamics) with NDSolve

Update-1: The initial conditions in the question were wrong/incomplete. (removed 1/0 errors) Update-2: The 1D Euler equations were modified to match this source. (ultimately not necessary in V10.4, ...
user avatar
  • 7,237
20 votes

Only final result from NDSolve

There is actually a somewhat cryptic but very simple way to make NDSolve only return the solution at the end point: ...
user avatar
  • 23.1k
20 votes

Mismatch between numerical and analytic evaluation of an integral

After a lengthy study (I'm using version 8) I conclude that there is a bug in Mathematica in the Integrate function when applied to a ...
user avatar
20 votes
Accepted

Obtaining an NIntegrate error estimate

From Anton Antonov's answer to Determining which rule NIntegrate selects automatically, we learn we can get the error estimate(s) using the undocumented option ...
user avatar
  • 217k
20 votes
Accepted

Plotting separatrices for nonlinear system

We can solve (approximately) for the initial conditions of solutions that approach an equilbrium by comparing the displacement vector from the equilibrium with the vector field of the ODE. Such ...
user avatar
  • 217k
20 votes
Accepted

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

Here are a few versions I use: 1) ...
user avatar
  • 36.1k
19 votes
Accepted

Boundary sphere partial differential equation

The differential equation should reflect the fact that θ ranges between 0 and Pi. Because ...
user avatar
  • 58.4k
19 votes

How much time should one give Mathematica for an integral evaluation?

For what it's worth, you can monitor the progress of Integrate and NIntegrate. I'm not sure how helpful the tools below are, ...
user avatar
  • 217k
19 votes

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

Note: fix is broken since v11.3, a new question has been started aiming at upgrade it. Here's my approach for fixing the difference order. The key idea is ...
user avatar
  • 52.8k
19 votes

NIntegrate doesn't evaluate

How can I force NIntegrate to calculate? Below are listed "forcing" answers. They should apply in a wide range of situations with minimal understanding of the integrands. Diagnosing First let ...
user avatar
18 votes

NIntegrate has a memory leak

The memory leak in NIntegrate is a bug and has been fixed as of version 10.2.0. Earlier versions would lose around 720 bytes per evaluation for this example, which ...
user avatar
  • 25.1k

Only top scored, non community-wiki answers of a minimum length are eligible