Questions tagged [numerics]

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

Filter by
Sorted by
Tagged with
44
votes
8answers
10k 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 ...
76
votes
9answers
5k 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 ...
47
votes
6answers
10k 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 ...
41
votes
3answers
2k 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: ...
24
votes
1answer
15k views

What do the X and Y axis stand for in the Fourier transform domain?

In Wolfram Mathematica the function Fourier has the following declaration Fourier[list] And after a list is given to the ...
28
votes
2answers
6k 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 ...
24
votes
6answers
4k 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 ...
8
votes
2answers
2k views

A problem about function N

Toady,I have a problem about N,described as below: For example N[1/3, 5] (* ==> 0.33333*) and ...
109
votes
1answer
2k 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 through version 10.0 the performance of a / b and a - b is ...
45
votes
3answers
2k views

Is manual adjustment of AccuracyGoal and PrecisionGoal useless?

This is a problem confusing me for years. AccuracyGoal and PrecisionGoal are two options that I never truly understand and, to ...
37
votes
2answers
2k 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 ...
35
votes
3answers
2k 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 ...
10
votes
1answer
579 views

Confused by (apparent) inconsistent precision

$$ e^{\pi \sqrt{163}} \approx 262537412640768743.99999999999925 $$ E^(Pi Sqrt[163.0]) N[E^(Pi Sqrt[163.0]), 35] NumberForm[E^(Pi Sqrt[163.]), 35] returns <...
39
votes
1answer
2k 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 ...
59
votes
11answers
5k views

Can Mathematica propose an exact value based on an approximate one?

Sometimes, I use Mathematica to do some hypothesis on homework to make the question easier. For instance, when I have to compute big sums when $n\to\infty$ and Mathematica can't give the exact answer, ...
3
votes
2answers
1k views

Unexpected result of summation

I wrote a small module that gives me an incorrect output-set. It should be a single number! I don't understand what went wrong. This is the form of summation used: $$\frac{1}{2} (b-a) \sum_{i=1}^n ...
72
votes
3answers
7k views

Numerically solving Helmholtz equation in 2D for arbitrary shapes

I would like to solve the Helmholtz equation with Dirichlet boundary conditions in two dimensions for an arbitrary shape (for a qualitative comparison of the eigenstates to periodic orbits in the ...
29
votes
2answers
886 views

Symbolic derivatives are being calculated numerically

Update: (1) By V11, not sure of the exact version, the derivative IntegerPart' has been given a symbolic definition. (2) The numeric derivative computed has changed ...
17
votes
5answers
1k 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 <...
11
votes
2answers
742 views

Dr. StrangeNumbers or: How I Learned to Stop Worrying and Love Floating Point Arithmetic

The following is the program. ...
23
votes
3answers
6k 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 ...
18
votes
2answers
660 views

NDSolve uses different difference order for different spatial derivative when solving PDE

I found something this tutorial for method of line doesn't tell us. Consider the following toy example: ...
16
votes
4answers
5k views

How do you round numbers so that it affects computation?

I'm trying to make a demonstration of how rounding to different numbers of digits affects things but I can't find a way to round numbers to a specified number of digits. The ...
17
votes
3answers
10k views

How to solve ODE with boundary at infinity

y''[x] - x y[x] == 0 y[0] == AiryAi[0], y[∞] == 0 The analytic solution to this ODE is the Airy function y[x] == AiryAi[x] ...
15
votes
1answer
3k 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: ...
20
votes
5answers
6k 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 ...
7
votes
2answers
775 views

Position function not always returning 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 ...
64
votes
3answers
3k views

When can I 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: machine-...
40
votes
3answers
4k views

Identifying critical points/lines 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 ...
29
votes
3answers
3k views

Numerical solution of coupled ODEs with boundary conditions

I have to solve the following set of ODEs and just can't get good results using Mathematica $$ r\frac{d}{dr}\left(\frac{1}{r}\frac{d}{dr}A(r)\right)-\xi^2F(r)^2\left(A(r)-1\right)=0 $$ $$ \frac{1}{r}\...
16
votes
3answers
3k views

Implement the Bisection algorithm elegantly and easily

Description: Rencently, I have finished my course Numerical Analysis, so I'd like to implement many algorithm that I have learned from that course.By this practice, I hope that I can improve my ...
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 ...
17
votes
2answers
849 views

New General::munfl error and loss of precision

The latest version 11.3.0.0 of Mathematica returns Indeterminate when evaluating Log[Exp[-800.]]. I believe this was not ...
18
votes
5answers
4k views

Numerical underflow for a scaled error function

I calculate a scaled error function defined as f[x_] := Erfc[x]*Exp[x^2] but it can not calculate f[30000.]. ...
14
votes
1answer
773 views

Converting to machine precision

There are multiple ways to convert an expression to machine precision, for example: ...
9
votes
3answers
931 views

Mod[1.2, 0.2] is not equal to zero

Why doesn't the following expression evaluate to zero? In[1]:=Mod[1.2, 0.2] Out[1]=0.2 Edit: This is what I wanted to do: ...
51
votes
1answer
3k 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 ...
35
votes
2answers
1k views

How to implement custom integration rules for use by NIntegrate?

How can NIntegrate be extended with custom implementation of integration rules? This answer of the question "Monte Carlo integration with random numbers generated ...
9
votes
3answers
413 views

Complex result for Real vectors in VectorAngle

I was expecting a real angle using VectorAngle when passing real valued vectors, but I obtained a complex angle: ...
32
votes
3answers
7k views

Global precision setting

Coming from Maple I do not understand how the precision for numerical computations in Mathematica is specified. I understand that there are various options to commands such as ...
22
votes
1answer
4k views

2D Heat equation: inconsistent boundary and initial conditions

I'm attempting to use NDSolve on a 2D boundary value problem with initial conditions. Upon running my code, I get the following message: "NDSolve::ibcinc: Warning: Boundary and initial conditions are ...
30
votes
8answers
1k views

Elegant high precision `log1p`?

Sometimes it is hard to understand how numerical expressions are evaluated. I remember reading claims by Wolfram on how smart the Kernel is to evaluate expressions trees numerically by recognizing ...
9
votes
3answers
1k views

Very different results from evaluating same expression with different precisions

When I evalute the following expression, ...
19
votes
6answers
1k 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: ...
4
votes
2answers
1k views

NIntegrate over a list of functions

This question is the result of these other two questions. Question 1 and 2. I thought it would be better to ask a new question rather than deleting previous one. I think When ...
20
votes
3answers
14k 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 ...
39
votes
1answer
2k views

How can I define a new symbolic constant like Pi?

There are a few builtin symbolic constants which behave like numbers, e.g. E, Pi, EulerGamma,...
39
votes
1answer
1k views

Is there a difference between Divide[a,b] and a/b?

In this comment it was asserted that Divide[a,b] and a/b are different, though the documentation indicates that they are the ...
5
votes
1answer
350 views

Variation of heat equation with guessed initial condition

Hi I am trying to solve a variation of the heat equation with interaction terms and external source -- actually it's the Schrödinger-Newton equation if that's more familiar to you. \begin{align} i \...
25
votes
3answers
2k 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 ...