Questions tagged [numerics]

Questions on the numerical functions of Mathematica, implementing numerical methods and numerical computing with Mathematica.

213 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
44
votes
0answers
2k views

Fast Spherical Harmonics radiative transfer

This is a rather specific question and I apologize for spamming you with some lengthy code. But it could be interesting for some reader and maybe you can help out, so please bear with me. I am using ...
14
votes
0answers
271 views

Bug? Numerical calculation error with FullSimplify and arbitrary precision

Bug introduced after 5.2, fixed in 8.0, reintroduced in 9.0 and persisting through 12.1 Is this a bug? If I do FullSimplify[n E^(0``10 n)] then it returns <...
10
votes
0answers
133 views

How to modify NDSolve`StateData without crashing the kernel?

Probably a hard question, but it's better to cry out loud. Reminded by Chris K, I noticed my fix function has been broken since v11.3. After some checking, I ...
8
votes
0answers
113 views

Bug in integral related to beta distribution

I've encountered a problem, which I'm pretty sure is a bug. I've contacted Wolfram's support and they were less than helpful. I'd like to bring the issue up here to get either a confirmation that it ...
8
votes
0answers
431 views

Mathematica 7: “LessEqual::nord:” error when using NMinimize on a real function

Bug introduced in 7.0 or earlier and fixed in 9.0 I encounter a problem (Mathematica 7) similar to Strategies to avoid LessEqual::nord in NMinimize? but the advised strategies don't work for me. Also,...
7
votes
0answers
125 views

Computing log-determinant?

Mathematica does-not have a function to compute the log-det of matrix? Naively computing Log[Det[M]] can be numerically unstable.
7
votes
0answers
1k views

Does NSolve find all solutions?

Is the solution set returned by NSolve usually complete? Can I assume that there are no more solutions than what it returns? Consider systems of equations e.g. ...
6
votes
0answers
67 views

What makes ListPlot better than N?

I wanted to numerically verify the validity of the formula for the first Stieltjes constant $$\gamma_1=-\frac12\sum_{n=0}^\infty\frac1{n+1}\sum_{k=0}^n\binom{n}{k}(-1)^k\log^2(k+1)$$ ...
6
votes
0answers
96 views

Details of NDSolve calling LSODA

Inspired by my question regarding the computation time of NDSolve using the LSODA backend I was wondering how NDSolve is actually calling LSODA (what arguments are sent to LSODA), i.e. what are the ...
6
votes
0answers
2k views

Numerically solving system of partial differential equation

I am trying to solve a system of partial differential equation with boundary conditions. But I got an error message saying NDSolve::icfail: Unable to find ...
5
votes
0answers
109 views

Change Branch Cut for DifferentialRoot

The differential equation eqn = (16 + q) g[q] + 4 q (-3 + q^2) g'[q] - 4 q^2 (-1 + q^2) g''[q] == 0 is singular at {-1,0,1}. ...
5
votes
0answers
137 views

Speed up computing the $n$-th hexadecimal digits of $\pi$, by using BBP formula

Let $$S_j=\sum_{k=0}^{\infty} \frac{1}{16^k(8k+j)}$$ Then $(n+1)$-th hexadecimal digit of $\pi$ given by the fractional part of $${\lbrace 4\lbrace 16^{n} S_1\rbrace-2\lbrace 16^{n} S_4\rbrace-\...
5
votes
0answers
72 views

How to pass a custom method to a particular option?

In an answer to my question More efficient method to compute moments of the Johnson $S_B$ distribution, J. M. has come up with a method to compute the moments of the Johnson $S_B$ distribution, which ...
5
votes
0answers
109 views

How to speed up solution of system of recurrence equations

I was wondering how I can improve the speed on this method for solving a particular system of coupled recurrence equations. The system is $$ \begin{align*} &V(m)=\alpha + \beta V(m+1)+\beta \sum_{...
5
votes
0answers
297 views

NMinimize seems to call function with the same values multiple times

I have to minimize a function where the evaluation of one parameter set takes very long (around 5sec) and discovered alongside, that NMinimize seems to call this ...
5
votes
0answers
190 views

Tools for Stability/Automatic Error Analysis in Mathematica

I have a longer analytic expression in several variables containing special functions and others. Does Mathematica bring tools - or are there any packages - to examine the stability when I evaluate ...
5
votes
0answers
770 views

A is fast, B is fast, but together they're Mathematica-crashing slow?

I'm trying to do something with finding solutions to a quantum mechanics problem with n wells. If there are 40 wells, I need to find the solution to an equation in the form: ...
5
votes
0answers
349 views

LeastSquare Solution for the Continuous Time Lyapunov Equation

I have been working with a problem which involves solving the continuous time Lyapunov equation $$A R + R A^\top = G$$ for the symmetric positive definite matrix $R$. Here $A$ is real, invertible ...
4
votes
0answers
151 views

Numerical backward induction — Solving sequential Cournot

I'd like to numerically solve a sequential Cournot competition in which supplier 1 moves before supplier 2, then the manufacturer sources from them, and finally sells the item at market clearing price....
4
votes
0answers
200 views

Using Numdifftools with ExternalEvaluate to calculate the Hessian

I need to compute numerically the Hessian of a numerical (scalar) function. Mathematica does not have a numerical Hessian routine (funny thing..) and so I am using this implementation. However, though ...
4
votes
0answers
271 views

Does Mathematica know that $\small\frac{\vartheta_3\left(0,\frac{1}{\sqrt[10000000000]{e}}\right)^2}{10000000000}$ not equal $\pi$

The following is not an identity but is correct to over 42 billion digits: $$\bigg(\frac{1}{10^5}\sum_{n=-\infty}^{\infty}e^{-\frac{n^2}{10^{10}}}\bigg)^2=\pi$$ I want to check this. I tried: <...
4
votes
0answers
227 views

Classification problem using SVM methods

I am running SVM on mathematica and I a used this code with classes: ...
4
votes
0answers
255 views

What am I missing in this highly oscillatory integral?

I want to numerically integrate this equation (in python without calling Mathematica): $\int_0^\infty {\rm d}k f(k) J_v(r k) J_n(s k)$ where $f(k)$ is a non-smooth function, $J_v$ are the Bessel ...
4
votes
0answers
684 views

Nonuniform Savitzky-Golay filter for smoothing and differentiation

The classical Savitzky-Golay filter works only with uniformly sampled data and currently we have at least two good implementations of it for Mathematica published on our site. But in many practical ...
4
votes
0answers
339 views

Stability analysis of transcendental equation (stability crossing curves)

I am working with a non-linear delay system with three scalar delays. After taking the Laplace transform of the linearized system, the characteristic function is a transcendental equation with three ...
4
votes
0answers
120 views

Is it possible to circumvent this overflow?

I'm trying to evaluate the following function numerically: $ f(A,B)=\frac{2A\pi ^{5/2} (-1)^B}{(A!)^2B!} \, _4\tilde{F}_3\left({\frac{1}{2},1-A,1-A,1-B\atop \frac{1}{2}-A,\frac{1}{2}-A,\frac{1}{2}-...
3
votes
0answers
70 views

Numerical Mixed Partial Derivatives: How to Choose Scale?

For illustration purposes, consider the function $$ f(x, y) = (x - 1)^2 + (y - 1)^2 + \sin[25(x+y)] . $$ The mixed partial derivatives at the origin are $f^{(x,x)}(0,0) = f^{(y,y)}(0,0) = 2$ and $f^{(...
3
votes
0answers
128 views

Discrepancy between the results of NIntegrate with different methods and options

I am trying to perform a numerical integration on a function defined through a sum of exponential terms. The summation is given by: ...
3
votes
0answers
73 views

Evaluating Lauricella functions of Third kind numerically in Mathematica

Let's consider the Lauricella function of third kind, denote as $F_{C}(a,b;c_1,...,c_n;x_1,...x_n)$ in MathWorld. Is anyone aware of an algorithm that allows to numerically evaluate such a function ...
3
votes
0answers
114 views

Can this integral equation problem $\int_\Gamma \frac{e^{ik|x-y|}}{4\pi|x-y|}\varphi(y) \, \mathrm{d} y = u_{x_0}^{in}(x)$ be solved?

I am not sure if Mathematica is capable of solving integral equations in 2D/3D. I found this page in the documentation, but this is just for 1D. The following is what I would like to solve, it can ...
3
votes
0answers
58 views

ContinuedFraction: different result with different representation of argument

Why if I write: In[7]:= ContinuedFraction[3.15] FromContinuedFraction[%] N[%] I get: ...
3
votes
0answers
185 views

On Ж, and the fine-structure constant

I'm trying to reproduce the results from a certain infamous paper that has been moving around the web for the last few days. The details are irrelevant. This paper claims to have a closed-form ...
3
votes
0answers
142 views

Unexpected Behavior of Parametric Sensitivity in ParametricNDSolveValue

Bug introduced in 10.4 or earlier and continuing through 11.3 Submitted as CASE:3916971 While exploring alternative methods of solving 33538, I encountered difficulties with the parametric ...
3
votes
0answers
67 views

Need expertise in controlling precision across calculations: specific case - elementary symmetric functions

I've seen several questions here concerning precision issues when performing multiple floating point calculations, but unfortunately got completely confused. I really don't understand what precision ...
3
votes
0answers
102 views

Memory used is not released after finishing a calculation

The series depends on a parameter. I numerically calculate consecutively series for different values of the parameter. When Mathematica finishes the calculation of the first point the memory used is ...
3
votes
0answers
149 views

Rationalize error

The docs state that "Rationalize[x,dx] yields the rational number with smallest denominator that lies within dx of x." However, testing this out it appears to be false. ...
3
votes
0answers
478 views

Computation of a Fresnel Diffraction pattern with Discrete Hankel Transform

In the next link: Computation of Hankel Transform using FFT (Fourier) Rainer implemented a great solution given in the next reference: Manuel Guizar-Sicairos and Julio C. Gutiérrez-Vega, "Computation ...
3
votes
0answers
105 views

Low accuracy while solving a multi-variable equation numerically

My question is as following: I was trying to make a function Vs2[r] with two parameters fit a set of conditions. Vs2[r]: <...
3
votes
0answers
343 views

NSolve doesn't work on an equation containing a numerical integral and constraints

I'm having trouble getting Mathematica to solve equations numerically. I know that its important to specify the type of variables for pattern testing (see e.g. here) but this doesn't seem to work. ...
3
votes
0answers
501 views

Speeding up a numerical constrained quadratic optimization

I'm trying to solve a quadratic optimization problem in 35 variables, $\vec{α} = \left< α_1, \ldots, α_{35}\right>$: $$ \begin{aligned} &\operatorname*{maximize}_\vec{α}&&1.0\cdot ...
3
votes
0answers
1k views

FindRoot gives a wrong solution which obviously should not be there

I got stuck on FindRoot and I didn't see any similar problem posted, so let me explain what I am trying to do and what problem I meet here. I try to find roots of a particular function, which in the ...
3
votes
0answers
630 views

Numerically solving PDE with high precision

I want to numerically solve the PDE $\partial_t u(t,x)=c\partial_x u(t,x)+(mx-l)u(t,x)$ with some initial and boundary conditions and given parameters $c$, $m$ and $l$. Consider the code ...
2
votes
0answers
100 views

NDSolve big system non linear coupled ODE's Method Residual Stiff System

I'm trying to develop a continuous time unscented Kalman filter for a dynamic system inspired to this article: "On Unscented Kalman Filtering for State Estimation of Continuous-Time Nonlinear ...
2
votes
0answers
49 views

Generalizing technique to handle General::munfl error?

In contrast to earlier versions of Mathematica, in versions 11.3 and later Mathematica no longer switches to arbitrary precision when it detects a MachineNumber underflow. While this behavior is ...
2
votes
1answer
162 views

(Numerical) calculation of nested integrals

The problem I'd like to (numerically) compute nested integrals of the type $$I(a;k) \equiv \left( \prod_{i=1}^k \int_0^\infty \mathrm{d}x_i \right) \exp \left( - \frac{1}{4a} \sum_{i=1}^k \left( x_i - ...
2
votes
0answers
53 views

Problem with stopping NDSolve after a condition is met

I'm trying to write a piece of Mathematica code that is essentially a differential equation solver that needs to take a specified function $V[t,q]$, and then numerically solves the differential ...
2
votes
0answers
60 views

Code to find the Covariant Lyapunov Vectors

I've been able to find a decent amount of existing resources for computing the Lyapunov Exponents for a system of differential equations. Is there any existing code/resources for computing the ...
2
votes
0answers
165 views

Solving a Modified Biharmonic Equation on a Square

I am seeking to solve the differential equation \begin{equation} \left[\partial_{\overline{x}}^{4}+2\left(1+\delta\right)\partial_{\overline{x}}^{2}\partial_{\overline{y}}^{2}+\partial_{\overline{y}}^{...
2
votes
0answers
101 views

Speeding up NIntegrate and DensityPlot

I'm making a density plot of a spectral function Sfull[kx, ky, kz, Ω] along a specified path in {kx,ky,kz}-space. The plot looks ...
2
votes
0answers
44 views

Why gives Modulo of complex numbers different answers for rationals and reals

When running Table[1.*Mod[(1 + I)^(1 + k*I), 1 + k*I], {k, 49, 50, 0.5}] Table[1.*Mod[(1 + I)^(1 + k*I), 1 + k*I], {k, 49, 50, 1/2}] I get for the first table <...

1
2 3 4 5