Questions tagged [numerics]

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

149 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
39
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 ...
30
votes
0answers
569 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 ...
13
votes
0answers
208 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 11.2 Is this a bug? If I do FullSimplify[n E^(0``10 n)] then it returns <...
8
votes
0answers
99 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
419 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
101 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 ...
7
votes
0answers
676 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
62 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
87 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
123 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
104 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
275 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
756 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
304 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

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
102 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
264 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
200 views

Classification problem using SVM methods

I am running SVM on mathematica and I a used this code with classes: ...
4
votes
0answers
223 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
522 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
116 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}-...
4
votes
0answers
183 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 ...
3
votes
0answers
44 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
171 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
129 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
98 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
94 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
135 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
387 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
96 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
254 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
687 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
287 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 ...
3
votes
0answers
256 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
463 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
614 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
35 views

When mapping FindMinimum to a list, how to find out which instance does not converge

I defined a function f[x,y] and wanted to study its minimum over x when viewing y as a ...
2
votes
0answers
65 views

Wrong result using “numeric” symbols

Recently I stumbled upon a weird bug when I used a package that sets the NumericQ result of symbols you are feeding into a certain function to true. Here is a minimal working example of what I mean: ...
2
votes
0answers
96 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 ...
2
votes
0answers
59 views

How to construct a time-dependent matrix quickly?

In the process of discretization of a 4D PDE, I need to construct a final sparse matrix $B$, which is very large (I denoted by $\text{size}$ here) and time-dependent, viz, some of its entries change ...
2
votes
0answers
139 views

Derivative of an interpolation function is noisy

I have a set of numerical data of 1501 points, in the form of $\{x_i,a_i\}$ which I uploaded to here and here. I need to compute the numerical derivative of this data. In particular, I need the ...
2
votes
0answers
294 views

How to Solve this Fokker-Planck Equation?

I need to solve this Fokker-Planck equation in Mathematica and my attempt to perform this integration is above: My first attempt is above: ...
2
votes
0answers
133 views

Extracting the curl-free component of a vector field

I am trying to extract the curl-free component of a discrete vector field. My plan is to take the Fourier transform of the vector field and then extract the radial component in Fourier space. The ...
2
votes
0answers
129 views

Why can Mathematica compute numerical sums more efficiently when they are written as matrix operations?

Let $f(n)$ and $K(n,m)$ be functions such that the double sum, which we wish to evaluate numerically, $$ \sum_{n=1}^a \sum_{m=1}^a f(n) f(m) K(n,m) $$ exists when $a$ is some large positive number. I ...
2
votes
0answers
53 views

Rescale large numerical factors in rational functions

Given a rational function $$ f(x_1,x_2) = \dfrac{r_1 x_1^2 + r_2 x_2}{r_3 x_1 + r_4 x_2}, $$ with $r_i$ arbitrary real or complex numbers, is there a built-in function to get Mathemtica to rewrite as $...
2
votes
0answers
208 views

Numerical integration: complicated 2D integral seems to be poorly estimated

In the course of some physics research I've been working on, a very annoying integral has appeared that I'm having difficulty evaluating numerically. Any help you could offer would be greatly ...