Questions tagged [numerics]

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

Filter by
Sorted by
Tagged with
16
votes
1answer
318 views

When does NDSolve parallelize ODE system solving?

I've long believed that NDSolve cannot make use of multiple cores to solve ODE system, but things seem to be different at least since v12. Consider the following ...
16
votes
1answer
423 views

What happened to SequenceLimit?

In older versions of Mathematica, there was a function called SequenceLimit that allowed taking the limit of a numerical sequence. It is useful for speeding up the ...
16
votes
2answers
495 views

Why is my data 10 times slower than random data when doing matrix multiplication

I have some data generated from some program, and it appears that matrix multiplication on these data are about 10 times slower than on some random data: ...
16
votes
2answers
2k views

How to compute the inverse CDF of HyperbolicDistribution properly?

Fixed in version 9. I want to compute the CDF and inverse CDF of the hyperbolic distribution: ...
16
votes
1answer
5k views

Parallelizing Numerical Integration in Mathematica

I have an ugly, six dimensional function that I need to integrate numerically. It works, but it currently take twelve hours to complete the calculation. Is there any good way to parallelize the ...
16
votes
2answers
3k views

Numerical partial derivative

For a one-variable numerical function, it's simple to calculate the derivative at a point with Derivative as Szabolcs has pointed out before: ...
16
votes
1answer
296 views

How does Plus work on machine precision Real arguments?

I thought Kahan's summation method would make a nice example for students to use to think about round-off error [W. Kahan, Pracniques: Further Remarks on Reducing Truncation Errors, Commun. ACM 8  (...
15
votes
3answers
5k views

Does Mathematica get Pi wrong?

I happened to watch a Youtube video on Pi. According to the video, the 1 millionth digit of Pi is 1. And here is another page of the first 1 million digits of Pi. You can get the same answer from ...
15
votes
4answers
488 views

Make mathematica treat $e_i^2$ as numeric

With NumericQ[symbol] = True, I can declare that a symbol is numeric. I want the expressions matching: $$e_{\text{i$\_$}?\text{IntegerQ}}^2$$ to be treated as ...
15
votes
3answers
1k views

How do I numerically evaluate and plot the Fabius function?

The Fabius function is a well-known example in analysis of a non-analytic function that is infinitely differentiable. I want to be able to numerically evaluate the function for any real argument, as ...
15
votes
1answer
602 views

Why is MainEvaluate being used when LinearSolve can be compiled?

According to this question LinearSolve can be compiled. However, CompilePrint[] shows a call to ...
15
votes
2answers
3k views

more numerically accurate inverse matrix

I encountered the following matrix mat = {{2, 2.161209223472559` + 1.682941969615793` I}, {2.161209223472559` - 1.682941969615793` I, 2}} and ...
15
votes
1answer
2k views

Poisson solver using Mathematica

I am looking for some help with a Poisson solver I am writing in Mathematica. The code is quite long with Arrays plugged in, so the full details can be found at http://pastebin.com/uSrSDcW6 I am ...
15
votes
1answer
2k views

ParallelEvaluate for function minimization

Is there a parallelized version of a minimization routine available in Mathematica? The objective function is non-linear and the gradients have to be numerically computed. Every function evaluation ...
15
votes
2answers
2k views

Is it possible to use the LevenbergMarquardt algorithm for fitting a black-box residual function?

I have a black-box multiargument multiparametric function of the type SRD[dataPoint_List,params_List] which accepts experimental data along with the parameters of ...
15
votes
1answer
486 views

RandomReal closed on left & open on right?

I have a number of algorithms that depend on uniform random reals in half-open intervals such as $[0,1)$. In particular, I need a (pseudo) random-number generator that produces machine-precision ...
15
votes
2answers
660 views

Why do NumberForm and Round apparently use different tie-breaking methods?

When rounding numbers (for example, rounding a real number to the nearest integer), the "round to nearest" rule is usually used. For example, 1.4 is rounded down to 1 and 1.6 is rounded up to 2. ...
14
votes
7answers
2k views

Numerical evaluation of a sum

I am trying to compute numerically NSum[(-1)^n/n^3, {n, 1, Infinity}]. Of course, using first Sum would work here, but often it'...
14
votes
2answers
503 views

Can Mathematica provide a reliable estimate of the numerical error from NDSolve?

In the Details section of the Mathematica documentation for PrecisionGoal, one is told that Even though you may specify ...
14
votes
3answers
2k views

Strategies to avoid LessEqual::nord in NMinimize?

When using NMinimize on functions with complex intermediate expressions (but a real end result), quite often one gets the error ...
14
votes
4answers
533 views

Terrible accuracy of DawsonF

DawsonF[30.] returns 0. The correct value is 0.016676... At least it prints a warning message, ...
14
votes
2answers
7k views

Numerically obtaining the inverse Laplace transform of data

I have been using several Mathematica packages to do numerical inverse Laplace transforms on known (expressible in closed form) expressions, $\tilde{f}(s)$. I am now being confronted with the more ...
14
votes
1answer
475 views

“ParametricSensitivity” in ParametricNDSolve

"ParametricSensitivity" is listed as a Method in the documentation for ParametricNDSolve, ...
14
votes
1answer
775 views

Non Standard Eigenfunction Plots of the Laplacian Over the Unit Square

I have recently been plotting eigenfunctions of the laplacian over the unit square using the NDEigensystem command. However, I have noticed something in the plots ...
14
votes
1answer
936 views

Converting to machine precision

There are multiple ways to convert an expression to machine precision, for example: ...
14
votes
1answer
723 views

Jacobian of ParametricNDSolve and FindRoot for the Three Body Problem

The main problem I took the time to reformulate the question in a more appealing and concise way. I want to find bifurcations of solutions to the three body problem. In order to do that, I define ...
14
votes
1answer
227 views

How is the Hessian computed using ``Experimental`NumericalFunction``?

Here and here it was explained how to use Experimental`NumericalFunction to compute the Hessian of a numerical function. I would like to know how this undocumented ...
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 <...
13
votes
4answers
1k views

Why is Poisson Random Deviate Generation so slow?

I am generating Poisson deviates for some numerical work. Mathematica 9.0.1 is very slow in generating these random numbers, as can be seen below. ...
13
votes
2answers
814 views

Is there a faster way to calculate Abs[z]^2 numerically?

Here I'm not interested in accuracy (see 13614) but rather in raw speed. You'd think that for a complex machine-precision number z, calculating ...
13
votes
5answers
989 views

NDSolve DAE with Constraints

I'm trying to make some numerical simulation with NDSolve. I have encountered a few problems. Here is a simplified version of the equations: ...
13
votes
3answers
263 views

Keep Round-Off errors for educational purpose

I want to show examples of round-off errors in some numerical algorithms to my student, in order to motivate the study of algorithms with a better behavior. While it is easy in any other language, I ...
13
votes
2answers
1k views

Water Hammer - Numerically solving system of PDEs

I'm trying to use Mathematica to solve the water hammer effect. ...
13
votes
1answer
130 views

Apply N only outside a certain function

1 + f[1] // N gives 1. + f[1.] I don't want the argument of f evaluated by N; I ...
13
votes
1answer
491 views

What strategies can I use to evaluate a limit when Limit[] returns unevaluated

I'm trying to find the following limit using Mathematica: $$\lim_{N\to\infty}\sum_{k=1}^N\left(\frac{k-1}{N}\right)^N$$ The problem is taken from here and is known to converge to $\displaystyle\frac{...
13
votes
1answer
1k views

How trustworthy is NMaximize?

Suppose I solve a constrained optimisation problem using NMaximize. How confident can I be of the accuracy of the result? For concreteness, suppose that F,G are (...
13
votes
2answers
11k views

How do you force a decimal output? [duplicate]

I have some very small values such as 2.601519253*10^-8. I'd like to output these values to CSV for another program to work with. I've tried N[value, 50], but Mathematica still insists on producing ...
13
votes
1answer
4k views

Kramers-Kronig relations

I am trying to calculate the change of the refractive index from the change of the absorption coefficient using the Kramers-Kronig relations, in Mathematica. ...
13
votes
1answer
493 views

Does NRoots own an abstract counterpart? If not, can we write one?

We know when solving linear algebra equations, despite its abstract syntax, LinearSolve is much faster compared to Solve: ...
13
votes
1answer
175 views

A weird issue with Interval[$MaxNumber]

Bug introduced in 9.0 or earlier and persisting through 11.0.1 or later From the Interval documentation: For approximate machine- or arbitrary-precision numbers ...
12
votes
3answers
2k views

Trying to find the asymptote to a function

I am trying to find the asymptote to a solution of a differential equation. I solved $x'(t) = \sin(x(t) + t)$ using NDSolve and plotted my solution. ...
12
votes
1answer
505 views

How can I reproduce the result of PrincipalComponents

...
12
votes
1answer
880 views

Is there a way to see the result of NIntegrate's symbolic preprocessing?

NIntegrate can do a number of different types of symbolic preprocessing on the integrand before starting the numerical calculations, including changes of variables. ...
12
votes
1answer
5k views

Is Abs[z]^2 a bad way to calculate the square modulus of z?

For a numerical quantity z, Abs[z] returns the square root of the sum of the squares of the real and imaginary parts of ...
12
votes
1answer
773 views

Why does 1 - Exp[-10.0^12] cause an out-of-memory error?

I would like to understand why evaluation of the expression 1 - Exp[-10.0^12] causes an out-of-memory error and how can I prevent such errors when calculating ...
12
votes
2answers
408 views

Wrong computation with N

I was trying to solve this problem using Mathematica 8.04. I did this: ...
12
votes
1answer
4k views

Minimization by Nelder-Mead

Finding a global minimum for this problem (non-linear optimization by the Nelder-Mead downhill simplex method) may not be possible, but by finding local minimum, I am expecting the value of the ...
12
votes
1answer
431 views

SymplecticPartitionedRungeKutta shows strange error

Bug introduced in 9.0 and fixed in 11.3.0 or earlier I tried to solve Hamiltonian system ($Q$ is a vector of all generalized coordinates, $P$ - of generalized momentum) $$ \frac{\mathrm{d} Q}{\mathrm{...
12
votes
2answers
864 views

Why does Arg'[1. + I] return -0.5?

From the document we know that Arg[z] gives the gives the argument of the complex number z. Then how about ...
12
votes
2answers
231 views

Last@Accumulate not giving same result as Total

If I run the code: arr = Table[0.979, 249]; Last@Accumulate[arr] - Total[arr] on Mathematica 11.0 (Windows), I get the result ...

1 2
3
4 5
36