Questions tagged [numerics]

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

182 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
43
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 ...
32
votes
0answers
650 views

Is MathieuC for moderately large imaginary arguments broken?

Bug introduced in 3.0 and persisting through 12.0 (reported as CASE:3208982) I'm trying to plot MathieuC[-3,0.3,I x] for $x\in[0,10]$, and here's what I get even ...
14
votes
0answers
251 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 <...
9
votes
0answers
114 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
107 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
428 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
91 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
889 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
64 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
78 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
97 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
130 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
107 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
288 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
187 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
764 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
333 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
182 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
112 views

How to extend a root finding method from 1D to multi dimensions

The number (0.25 Pi) is a third order root of f[x] below. Clear[f]; f[x_] := Sin[x] - Cos[x] - Sqrt[2] (x - 0.25 Pi); Chop@Normal@Series[f[x], {x, 0.25 Pi, 4}] -...
4
votes
0answers
267 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
212 views

Classification problem using SVM methods

I am running SVM on mathematica and I a used this code with classes: ...
4
votes
0answers
243 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
599 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
321 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
119 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
125 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
60 views

Why this change gives different results in Integrate?

I'm new in Mathematica and can't understand why changing a number from Real to Integer is giving different results in my equations: ...
3
votes
0answers
56 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
47 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
182 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
136 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
116 views

Why does the domain of an interpolating function not match the corresponding ParametricNDSolve solution range?

Question I had believed - and mostly observed - that when I use ParametricNDSolve the obtained ParametricFunctions given as the ...
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
101 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
145 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
435 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
290 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
731 views

NDSolve fixed step problem

Working example here: Drive folder (have both files in the same directory! Notice: the line <<variables' in the file seems to throw an error for me, but ...
3
votes
0answers
265 views

Understanding NDSolve::ndsz

I'm working on a largeish system of differential equations where I encounter the NDSolve::ndsz step size is effectively zero; singularity or stiff system suspected ...
3
votes
0answers
481 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
623 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
1answer
58 views

Using functions instead of lists in physics numerical problems

I'm using the following code for calculation of reflection and transmission coefficients through square well potential: ...
2
votes
0answers
38 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 <...
2
votes
0answers
27 views

Need a generalization of NumericalMath`NSequenceLimit to incomplete data

NumericalMath`NSequenceLimit is a great tool to obtain an empirical estimate of the limit of a sequence whose exact behavior is unknown, just from a finite prefix ...
2
votes
0answers
45 views

Computing the first eigenfunction of the p-Laplacian in a real interval

How can I numerically compute the first (non-negative) eigenfunction $u$ of the $p$-Laplacian ($p>1$) in a bounded interval $(-a,a) \subset \mathbb R$ (up to positive multiplicative constant)? $$-\...
2
votes
0answers
66 views

Why is the sum of the series calculated using the integral

I tried to calculate the sum the Harmonic series via NSum up to a huge limit and got an error: NIntegrate: Numerical integration converging too slowly; suspect one of the following: singularity, ...