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

learn more… | top users | synonyms (1)

32
votes
6answers
4k views

Finding real roots of negative numbers (for example, $\sqrt[3]{-8}$)

Say I want to quickly calculate $\sqrt[3]{-8}$, to which the most obvious solution is $-2$. When I input $\sqrt[3]{-8}$ or Power[-8, 3^-1], Mathematica gives the ...
39
votes
8answers
2k views

Updating Wagon's FindAllCrossings2D[] function

Stan Wagon's Mathematica in Action (second edition; I haven't read the third edition and I'm hoping to eventually see it), demonstrates a nifty function called ...
16
votes
6answers
1k views

Annoying display truncation of numerical results

I have a lot of data to inspect. An example of a number in my program is 123.189094 This gets displayed as 123.189 ...
14
votes
2answers
1k views

How to fit 3 data sets to a model of 4 differential equations?

I'm a biologist and a newbie in Mathematica. I want to fit three data sets to a model consisting of four differential equations and 10 parameters. I want to find the parameters best fitting to my ...
13
votes
1answer
523 views

Funny behaviour when plotting a polynomial of high degree and large coefficients

I am trying to plot a polynomial of degree 29 on the domain [0,1], with fairly large coefficients: ...
25
votes
2answers
925 views

Meaning of backtick in floating-point literal

If I compute, say, 1/3//N, Mathematica displays 0.333333 as the result. When I copy that output to use elsewhere, the paste ...
10
votes
1answer
1k views

Combined numerical minimization and maximization

I want to numerically calculate the maximum of a function defined by the minimization of another function, like the following: ...
15
votes
6answers
4k views

About multi-root search in Mathematica for transcendental equations

I have some questions for multiroot search for transcendental equations. Is there any clever solution to find all the roots for a transcendental equation in a specific range? Perhaps ...
16
votes
5answers
2k views

The difference between 0. and 0

I have a function for which 0 is a special case: f[A___, 0, B___] := 0 But since I am doing numerics, sometimes in the course ...
42
votes
3answers
1k views

When I can assume that all decimal digits returned by Mathematica are provably correct?

How to Control the Precision and Accuracy of Numerical Results Arbitrary-Precision Numbers Mathematica works with exact numbers and with two different types of approximate numbers: ...
16
votes
5answers
602 views

Is this the most efficient way to round approximate integers to integers while leaving other Reals untouched?

This might seem like an overly simple question, but I need to specify custom plot tick marks as integers (no trailing decimal point) if they are approximately integers, but not if they are not. Using ...
8
votes
2answers
360 views

Precision differences

I run this sum and get the symbolic answer below : Sum[ (1/(k^2 - k) - 1/k^2), {k, 2, Infinity}] $2 - \frac{\pi^2}{6}$ I look up the sequence on OEIS and ...
2
votes
2answers
223 views

Position function not always retuning an answer even with no apparent problems

I'm having some problems with Position. Sometimes it will give an empty list instead of the actual position of the element I am looking for when that element is ...
35
votes
1answer
1k views

Adaptive sampling for slow to compute functions in 2D

EDIT: Although I have posted an answer based on my current progress, this in incomplete. Please see the "open issues" section in the answer. Most plotting functions in Mathematica adjust the ...
4
votes
1answer
694 views

Symbolic integration in the complex plane

Context While answering this question, I defined (symbolic and numerical) path integrations as follows ...
17
votes
1answer
974 views

Optimizing a Numerical Laplace Equation Solver

Laplace's Equation is an equation on a scalar in which, given the value of the scalar on the boundaries (the boundary conditions), one can determine the value of the scalar at any point in the region ...
17
votes
3answers
339 views

How to flush machine underflows to zero and prevent conversion to arbitrary precision?

I'm working on some pretty intense computation in Mathematica; when my code started running slowly, I tracked the source of the problem to Exp[]. I need to ...
13
votes
1answer
973 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 ...
12
votes
3answers
2k views

Solving a Volterra integral equation numerically

I would like to solve for $P(t)$, in Mathematica, a Volterra integral equation of the 2nd kind. It is: $$P(t) = R_0(t) + \int_0^t P(t') R_0(t-t')dt'$$ I know the function $R_0$ and would ...
8
votes
4answers
695 views

Numerical integration of a numeric data available as a nested list

I have some numerical data in the form of a list with the following structure: {...{x,y,z},...} defining a surface z=z(x,y) in a 3D space (x,y,z). The data came from a simulation, and I am ...
12
votes
4answers
1k views

Numerical underflow for a scaled error function

I calculate scaled error function defined as f[x_] := Erfc[x]*Exp[x^2] but it can not calculate f[30000.]. ...
17
votes
2answers
222 views

Symbolic derivatives are being calculated numerically

Just found the following while debugging a problem. Mathematica is calculating the derivative of IntegerPart[x] in some odd way: ...
11
votes
1answer
2k views

Kramers-Kronig in Mathematica

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. ...
10
votes
1answer
230 views

How to work with Experimental`NumericalFunction?

This question is intimately connected with previous one: "How to create internally optimized expression for computing with high WorkingPrecision?" Oleksandr R. correctly states in the comment: A ...
27
votes
5answers
2k views

Identifying critical points of 2/3D image/cubes

Upshot I am interested in identifying critical points of a 3D field/cubes (maxima, minima, tube-like and wall-like saddle points) and 2D field/image (maxima, minima, saddle points). I.e. the ...
36
votes
1answer
875 views

How to compare power towers in Mathematica?

First I tried it directly, but it overflowed: ...
16
votes
2answers
940 views

Higher order periodic interpolation (curve fitting)

I have a list of points in 3D, and I want to get a smooth interpolation or curve fit (it is more for illustration) of these points such that the first and second derivatives at the start and end ...
9
votes
3answers
2k views

How can I differentiate Numerically?

Mathematica has two ways to integrate: Integrate and NIntegrate. But what about D? ...
8
votes
2answers
2k views

How to discretize a nonlinear PDE fast?

I wish to numerically solve the following PDE. Although there are some complete discussions for solving PDEs in tutorial/NDSolvePDE, there is no hint for the nonlinear case by discretization. Thus, I ...
10
votes
1answer
794 views

How do I find all the solutions of three simultaneous equations within a given box?

Sometimes, one needs to find all the solutions of three simultaneous nonlinear equations in three unknowns $$\begin{align*}f(x,y,z)&=0\\g(x,y,z)&=0\\h(x,y,z)&=0\end{align*}$$ within a ...
11
votes
1answer
207 views

How to create internally optimized expression for computing with high WorkingPrecision?

I have large dataset and need to fit rather complicated function on it with different values of one of its parameters (this parameter must be fixed in every fit). I use the ...
11
votes
2answers
561 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 ...
13
votes
3answers
341 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 ...
11
votes
1answer
320 views

Why is MainEvaluate being used when LinearSolve can be compiled?

According to this question LinearSolve can be Compiled. However, CompilePrint shows a MainEvaluate but no-warning is generated. It appears that LinearSolve is not ...
3
votes
1answer
215 views

How can I deal with a non-numerical value for a derivative at $t = 0$ when using NDSolve?

I want to solve two coupled equations with NDSolve, ...
11
votes
1answer
2k views

What method does NDSolve use for solving PDEs?

What is NDSolve's mode of operation? I use it to solve partial differential equations and never gave it too much thought. Recently, I came across this question. ...
8
votes
1answer
298 views

ReplaceAll[] and Limit[] don't give correct results for this expression under extreme variables [duplicate]

Possible Duplicate: Funny behaviour when plotting a polynomial of high degree and large coefficients 1/x^2 + (3 + x)/(6 (1 - Exp[x] + x)) ——This is a ...
0
votes
1answer
252 views

What is the correct way to use NIntegrate inside the FindMinimum function?

I'm having minor issues with the FindMinimum function when using NIntegrate inside. The functions work perfectly well but I get ...
62
votes
2answers
678 views

Why are numeric division and subtraction not handled better in Mathematica?

There is something that has been troubling me for a while. At least in version 7, the performance of a / b and a - b is not ...
23
votes
4answers
881 views

How to use NDSolve to track equilibrium?

I am looking for an extension of NDSolve where integration runs until certain variables are settled at an equilibrium. Now I have a working solution in my sleeves ...
7
votes
1answer
194 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. ...
10
votes
3answers
2k views

NDSolve with Euler method

I want to solve this equation with NDSolve[] using the Euler method: x'[t] == 0.5*x[t]-0.04*(x[t])^2 with initial condition ...
7
votes
2answers
472 views

How to apply restrictions to the “integrated” variable, when using NDSolve?

I have to integrate an energy along a path. I know the energy at the "beginning" of the path (energy[0]), and I can determine the energy change (gain and loss) ...
12
votes
2answers
632 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: ...
15
votes
4answers
400 views

How to remove duplicates from set of machine precision 2D points?

I have a set of 2D points with machine precision coordinates. I need to remove all duplicates. Performance is important. This is the most obvious fast solution: ...
13
votes
3answers
766 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 ...
7
votes
1answer
706 views

Handling failed FindRoot calls

I want to handle FindRoot calls which did not converge (e.g "thrown" error message FindRoot::cvmit) ...
15
votes
3answers
713 views

Can Mathematica Handle Open Intervals? Interval complements?

Open Intervals Following up on this question, I was wondering whether Mma can handle open intervals. For example, the union of the intervals, $$1<x<5$$ and $$5<x<8$$ should not ...
10
votes
1answer
235 views

Converting to machine precision

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

Function to subdivide interval into n evenly-spaced points

[This post needs better tags than I could come up with. Edits to the tags would be particularly welcome.] I realize that it is trivial to define a function that takes an interval (i.e. two ...