Questions on the use of numerical functions NIntegrate and NDSolve.

learn more… | top users | synonyms

8
votes
1answer
894 views

The difference between “SymbolicProcessing” -> 0 and restricting the function definition to numeric values only

The Documentation tells us that there are two ways to disable symbolic processing of the integrand by the NIntegrate function when it is known that it just slows ...
8
votes
1answer
267 views

Using a Mathematica index as a DiscreteVariable in NDSolve when solving a coupled set of ordinary differential equations

Context Since the explanation below of the problem to be solved is lengthy, let me preamble this by saying that I have code that works to solve the problem, but I don't know whether (1) it's ...
8
votes
2answers
824 views

Numerical contour integrations in the complex plane - contour deformation gives different answer for analytic kernel

I am trying to do a contour integration in Mathematica numerically. In particular, I'm checking the identity: $$ H_m^{(1)}(z) =\frac{i^{-m}}{\pi}\int_{-\pi/2 + i \infty}^{\pi/2 - i \infty} \exp[i m ...
8
votes
1answer
69 views

Working Precision in nonlinear control systems

When simulating a nonlinear control system using StateResponse , do the options WorkingPrecision, ...
8
votes
0answers
2k views

Integro-differential equation [closed]

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|) ...
7
votes
3answers
364 views

Where did I go wrong with my implementation of the trapezoidal rule?

One method for doing quadrature, called the trapezoidal rule, improves accuracy by connecting the points on the curve corresponding to the points of subdivision with line segments, forming trapezoidal ...
7
votes
3answers
3k 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 ...
7
votes
2answers
394 views

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

Sometimes when I do integrals in Mathematica (M), it keeps thinking and thinking and I have no idea what is going on inside M. For how long should one wait or how does one know whether M has not got ...
7
votes
2answers
333 views

Plotting the image of a curve under a flow

I have some explicit time-independent vector field on the plane, and I would like to study how points evolve under the flow generated by this vector field. The flow is rather complicated and cannot be ...
7
votes
4answers
650 views

Conditional numerical integration boundaries

I have a multidimensional integration of the form: ...
7
votes
3answers
3k views

How to use results of NDsolve[] for further solving of ODEs?

I have a system of ODEs with 10 eqns. I can solve the first 5 independently. How can I use those results to solve for the remaining 5? An easy example would be $\dot{x}=f(x), \quad \dot{y}=g(x,y)$ ...
7
votes
2answers
170 views

Multiply integrand with -1, and the precision changes?

"After multiplying the integrand of NIntegrate with -1, the Precision of the output will ...
7
votes
2answers
122 views

inspecting step size and order of $\tt NDSolve$

I am trying to collect information about what step sizes and what orders is using NDSolve internally. I tried wrapping it into a ...
7
votes
2answers
3k views

Finding y given x from an interpolating function

I would like to put a dot on the point of a curve that has a specific y value but I don't know the x value. A simple example of my code is ...
7
votes
2answers
1k views

How to set the NDSolve method to LSODA

I notice that off all the Method options available for NDSolve[...], LSODA is invoked quite ...
7
votes
2answers
228 views

How to locate the position of a periodic orbit

These are the equations of the dynamical system ...
7
votes
2answers
258 views

NIntegrate fails to converge under almost any PrecisionGoal, MinRecursion etc. How can I trust the result?

I have been getting some ideas by reading other related questions in the forum, but the integral I have to do is not converging in many cases. The integrand is of the form: ...
7
votes
1answer
353 views

Jumps in NDSolve results

I need to compute using NDSolve routine, some function $F(x)$, having two possible values $F_1(x)$ and $F_2(x)$ depending on whether the argument exceeds some ...
7
votes
1answer
838 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 ...
7
votes
1answer
94 views

Integrate yielding a ConditionalExpression but I don't think the condition is necessary

Suppose I take the PDF of the LogNormal distribution with parameters m and s evaluated at x. I obviously get an expression involving m. I now want to integrate that expression not with respect to x ...
7
votes
2answers
340 views

How to force Mathematica to throw an error for NIntegrate

Consider this: NIntegrate[BesselJ[2, x], {x, 0, Infinity}] 0.9999999999904574 This is the correct answer. Now: ...
7
votes
2answers
364 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: ...
7
votes
1answer
194 views

Difficulty in getting correct Gaussian curve for diffusion of point source

I want to solve diffusion of a point source numerically and check it against analytical solution. first I define initial profile, ...
7
votes
2answers
236 views

How to do multi-dimensional principal value integration?

The toy model is: $$\int_{-2}^{2}\int_{-2}^{2}\frac{1}{1-(x^2+y^2)}\, dx\, dy$$ The integrand have opposite sign across the circle $x^2+y^2=1$, so one would expect that the integral has meaning only ...
7
votes
2answers
541 views

Integrating a function over a surface integral

From a first principles bandstructure calculation I get an energy scalar field in three dimensions $E(x,y,z)$. It's now easy to plot a constant energy (contour)-surface for dedicated values ...
7
votes
1answer
832 views
7
votes
1answer
160 views

Numerically evaluating an integral related to Cantor's staircase

Cantor's staircase $F_C(x)$ is a well-known "pathological" function: Plot[CantorStaircase[x], {x, 0, 1}] The MathWorld link given above claims that $$\int_0^1 ...
7
votes
1answer
277 views

NMinimize with NIntegrate (crash in symbolic evaluation, memory leak)

This is a "common" problem from what I've seen, but with a different spin. I have a function I use often that finds a fit of an expression to another expression with some free parameters (e.g. for ...
7
votes
1answer
192 views

Detecting nearly simultaneous WhenEvents in NDSolve

I am trying to solve a system of (many) coupled nonlinear ODEs. I need to decouple some of the equations (i.e. set the time derivatives of some of the dependent variables to zero) at various points in ...
7
votes
1answer
124 views

Unify the sampling of NIntegrate[ {f, g, h} w ]

I'm trying to numerically integrate a function which has a vector-valued slow part and a much faster component which is shared by all the components, i.e. an integral of the form $$ ...
7
votes
1answer
659 views

Fitting a numerical integral via NonLinearModelFit to magnetic data

I'm new to Mathematica and I'm currently trying to fit $$m_T (H,T) = N_T \int\limits_0^{\infty} \frac{x k_\text{B} T}{\mu_0 H} \mathcal{L}(x) \text{pdf}(D_\text{mag}) \text{d}D_\text{mag}$$ with ...
7
votes
2answers
392 views

NDSolve Plotting issue

I am trying to solve a system of ODEs with one extra boundary condition. ...
7
votes
0answers
616 views

Modelling Hysteresis with a Differential Equation

I want to implement the bulk ferromagnetic hysteresis model (mostly the Jiles-Atherton Model), see http://drum.lib.umd.edu/bitstream/1903/6043/1/PhD_99-1.pdf page 44 equation (30). The needed ...
6
votes
2answers
506 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 ...
6
votes
3answers
622 views

RK4 Gravity Simulator

I have the following RK4 solver which splits the two 2nd order ODEs, used to calculate x and y positions under the influence of a gravitating body where $$x''(t)=\frac{G m ...
6
votes
2answers
499 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
800 views

Numerical solution of a differential equation with NIntegrate coefficients

I am trying to solve a linear ODE with a variable coefficient which is given in terms of an integral I can only do numerically. That is, I have an equation of the form $$ ...
6
votes
2answers
3k views

Is it possible to compute with the trapezoidal rule by numerical integration?

Is it possible to compute trapezoidal rule numerical integration? I know that Mathematica has Interpolation, and that a list of points can be interpolated and then ...
6
votes
1answer
119 views

code is ignoring WhenEvent

I would like the value of x[t] to be equal to 0 when it has a negative value so I used WhenEvent but it has no effect on my code ...
6
votes
3answers
147 views

Force WhenEvent to respect default stepsize

I have to numerically integrate an equation system and monitor the accumulating datapoints. For example, I fit a line to a subsample of the points and terminate via ...
6
votes
2answers
212 views

Reject diverging solution of NDSolve

I'm trying to numerically simulate a spring system with complex stiffness. In essence systems of the form $x''(t)+ (a+ ib) x(t)=0$ For this simple example an analytic solution is easy to find. The ...
6
votes
3answers
569 views

Numerically integrating a list-valued function [duplicate]

I want to NIntegrate a List valued function foo[x] which is only defined for numerical ...
6
votes
2answers
299 views

An integral with a fractional part in 3 dimensions

The evaluation with Maple suggests the triple integral is around $1$, but Mathematica tells it's $0.0958758$. When using the code ...
6
votes
2answers
263 views

Solving the path of Earth around Sun

This maybe isn't a universally helpful question. Maybe a little of a code dump. But here goes. I'm trying to solve the path Earth moves around Sun from Earths mass, Suns mass, Earths initial velocity ...
6
votes
3answers
196 views

Certain integral over torus

Let $F(t_1,s_1,t_2,s_2)=$ $$\big((2+\cos t_1)\cos s_1 - (2+\cos t_2)\cos s_2\big)^2 + \big((2+\cos t_1)\sin s_1-(2+\cos t_2)\sin s_2\big)^2 + (\sin t_1 -\sin t_2 )^2.$$ I am interested in computing ...
6
votes
1answer
291 views

Strange Behaviour of NIntegrate

I found some of the values remained unevaluated using the following code Table[NIntegrate[Sin[i x]/((2^x + 1) (Sin[x])), {x, -Pi/2, Pi/2}], {i,70, 90}] Pick them ...
6
votes
2answers
247 views

When analytical and numerical methods do not agree - Case study with Maximum Likelihoods methods

Here is the probability distribution I am interested in: $$P(q)=C e^{4 n s q} q^{4 n \nu - 1} (1 - q)^{4 n \mu - 1}$$ , where $e$ is the constant of Euler and $C$ is constant so that the whole thing ...
6
votes
2answers
203 views

Why does Nintegrate keep unevaluated?

Bug introduced in 10.0 and fixed in 10.2.0 It's no surprise that the "MonteCarlo" Method works well: ...
6
votes
2answers
210 views

How to use WhenEvent with a vector ODE in NDSolve

I have an ODE system I'd like to specify as a vector equation in NDSolve. I'm not clear on how to use WhenEvent for a system ...
6
votes
1answer
905 views

WhenEvent in NDSolve

How come this doesn't work as I intended? ...