Questions tagged [numerics]

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

Filter by
Sorted by
Tagged with
12
votes
1answer
685 views

Synchrotron Radiation and ListDensityPlot

I'm trying to reproduce the following plots: As described by this blog entry: Synchrotron radiation As you can see in the linked article, the task is essentially to make a ...
12
votes
2answers
2k views

Why can't I change the value of MaxRecursion in NIntegrate when integrating BesselJ?

Bug introduced in 8.0.4 or earlier and persisting through 11.0.1 or later I am trying to evaluate this integral numerically $$ \int_0^{\infty } J_0(q R) \tanh(q) \, \mathrm{d}q $$ for large values ...
12
votes
2answers
639 views

Preventing Numerical value from being evaluated

I have searched stackoverflow (and comparable pages) for quite a while now (got redirected from there to this specialized stack), and I surrender. I am trying to evaluate an expression that is small ...
12
votes
1answer
984 views

NDSolve and memory usage

After some googling, i've found similar problems around, but didn't find a 100% satisfactory answer, so let me ask here: I'd like to solve a 1+1 problem using the method of lines. In spherical ...
11
votes
5answers
486 views

Function for a series of joined slopes

I need a function for a series of joined slopes and my solution feels a bit kludgy. Is there a better way? A list of pairs of transition points and slopes: ...
11
votes
4answers
1k views

How to find the next root larger than a specified value, numerically?

I would want to have a general-purpose, reasonably robust method of finding the next numerical root above a specific value of x. I'm stumped by the fact ...
11
votes
2answers
852 views

FEM: Nicer Element Shape for Spherical Region

I'm trying to generate a mesh for later use in the Finite Element Method of the DSolve command. It is basically a parallelepiped with a spherical indentation. I'm ...
11
votes
2answers
689 views

Understanding simple numerical calculation

I am trying to understand why N[0.1]//FullForm returns 0.1' (A). Indeed, $0.1$ in base two is $0.000110011001100110011...$. If I ...
11
votes
2answers
422 views

Nonlinear dispersal equation modeling insect aggregation

I'm a newbie with Mathematica, I know it's a basic answer, but I can't solve the problem on my own. I have the following equation reflecting insect aggregation at low population densities (taken from ...
11
votes
2answers
679 views

Solving Cahn-Hilliard equation: LinearSolve: Linear equation encountered that has no solution

I have built the Cahn-Hilliard Eqs. in MMA (Mixed Formulation, second order), However, it doesnot work in MMA using Finite Element. LinearSolve: Linear equation encountered that has no solution. And ...
11
votes
2answers
778 views

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

The following is the program. ...
11
votes
3answers
409 views

Fast pairwise SameQ test of an ordered list

I have an ordered list of $N$ numbers, and I want to find out whether adjacent numbers are SameQ or not, returning a list of 0s and 1s of length $N-1$. One approach ...
11
votes
3answers
1k 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: ...
11
votes
2answers
759 views

Wonky Solutions to Schrödinger Equation with Box Barrier

I'm trying to solve the Schrödinger equation using NDSolve in a case where there is a potential box barrier. The initial condition is a cosine wave, and for ...
11
votes
2answers
460 views

Numerically solving Helmholtz equation in 2D for a Guitar

Hi I am new to using Mathematica, so am not too confident. I am essentially trying to model vibrations of a guitar sound board for a project. It would be great to get some visualisations of the ...
11
votes
1answer
4k views

How to solve fluid flow problem based on Navier-Stokes equations? [duplicate]

Does anyone know or can provide any examples how fluid flow problem can be formulated and solved in Wolfram Language? Simplest cases of 1D or 2D flows based on Navier-Stokes equations or even their ...
11
votes
2answers
658 views

Solve a PDE over a region defined by a Bézier patch

I am using NDSolve to find the solution to a PDE over an arbitrary domain. The domain is specified by a Bézier patch. ...
11
votes
1answer
383 views

Vastly incorrect answers obtained by increasing WorkingPrecision with modified Bessel functions

Bug introduced in 7.0 or earlier and fixed in 11.0 This is a follow-up to this question regarding numerical instabilities occurring with modified Bessel functions. In trying to explore J.M.'s answer ...
11
votes
1answer
1k views

What are the hidden specifications for FindRoot

The Help page of FindRoot says: "by default, FindRoot uses Newton's method (Newton-Raphson) to solve a nonlinear system" (or a nonlinear equation I suppose). ...
11
votes
2answers
691 views

Converting other C++ classes to MTensor in LibraryLink

Hopefully this will be a quick question + a quick answer: Say I have a C++ (or C) code using LibraryLink. I am using a library that defines a specific matrix class, as many numerical libraries ...
10
votes
5answers
620 views

Why does NMaximize miss this global maximum?

I am having trouble maximizing a function which appears as a curvature of a planar curve. ...
10
votes
4answers
910 views

Distances between points in periodic cube

Question How can one implement more efficiently/elegantly/memory savvily the following function which returns a matrix of all Euclidian distances between points in 3D within a cube of width ...
10
votes
3answers
1k views

Why does N[1.000 01, 10] return 1.00001, but N[1.000 001, 10] returns only 1.?

Why is it so? When I ask for N[1.00001, 10] I get quite reasonably 1.00001 But when I ask for ...
10
votes
2answers
649 views

Morphing between two functions

Assume we have 2 peaked positive functions f[x_] := Exp[-(x + 3)^2] g[x_] := 1/2 Exp[-(x - 3)^2/4] that look like Would it be possible to numerically find a ...
10
votes
2answers
907 views

Why is Mathematica destroying this graph?

Here I have a picture of a function I graphed: reg[x_,y_]:=(x^2+y^2)Cos[4ArcTan[y/x]]; Plot3D[reg[x,y],{x,-2,2},{y,-2,2},AxesLabel->Automatic] And here is ...
10
votes
3answers
984 views

What is the fastest way to compute digits of $\pi$ using Mathematica?

There are a lot of ways to calculate digits of $\pi$ using Mathematica. The most naïve way I can think of is N[π, 100000000] Of course, there are a lot of fast ...
10
votes
2answers
267 views

Demonstrating the behavior of a function as its independent variable approaches zero

I have several questions regarding the function $$f(x)=\frac{\sqrt{x^2+9}-3}{x^2}$$ that I would like to help my students with in the upcoming semester. Now, the limit as $x\to 0$ is 1/6. ...
10
votes
3answers
546 views

Wrong results from NSolve on coupled polynomials. WorkingPrecision -> Automatic fails

OP UPDATE: I received an email from WR on 1-18-2016: "...It does appear that the NSolve function is not behaving properly in this case and I have forwarded an incident report to our developers with ...
10
votes
2answers
969 views

Kernel quits without error in NDSolveValue

The crash is fixed in version 10.3 I am using the latest 10.1. The following single line command makes the kernel quit without error message (just a beep): ...
10
votes
4answers
5k views

Solving a linear system with a badly conditioned matrix

My question is related to this one: Badly conditioned matrix (General::luc) I'm trying to solve a linear system of the form A.x=b. As suggested in the referenced post since I'm not really interested ...
10
votes
2answers
4k views

Nonlinear PDE solver

I would like to solve the following nonlinear PDE: $$ \frac{\partial^2 \phi}{\partial x^2} - \frac{\partial^2 \phi}{\partial t^2} = \lambda |\phi|^2 \phi $$ I was trying: ...
10
votes
2answers
816 views

Problem with numerical evaluation of analytically solved integral, solution way off

The following command in Version 9.0.1: N[Integrate[x^50*Sin[x], {x, 0, 1}]] gives $1.4615\times 10^{48}$ which is way off from the correct solution which is ...
10
votes
4answers
2k 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 post-...
10
votes
2answers
885 views

Fitting experimental data by using ParametricNDSolveValue and NonlinearModelFit

I am a newcomer to Mathematica. Basically I just want to fit the data (enzyme kinetic data) shown below to a system of odes' by using NonlinearModelFit. The data, an 101x2 array, contains time in the ...
10
votes
1answer
10k views

Forcing FindRoot to return only real solutions

FindRoot documentation reports that if the equation and the initial point are reals, the solutions are searched in the real domain. However, in the following case I ...
10
votes
1answer
2k views

Handling failed FindRoot calls

I want to handle FindRoot calls which did not converge (e.g "thrown" error message FindRoot::cvmit) ...
10
votes
1answer
623 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 <...
10
votes
2answers
474 views

Finding self-intersections of a closed curve represented by an interpolation function

I've been trying to find particular simple closed curves on a plane. ...
10
votes
1answer
1k views

Nonlinear ODE eigenvalue problem

How does one find eigenvalues $\lambda$ of the following problem? $$ \frac{\mathrm{d}^2 u}{\mathrm{d}x^2} = \lambda \left( -u + u^2 \right),$$ $$ u(0) = u(1) = 0. $$ Can this be tackled by ...
10
votes
2answers
649 views

Symbolic Integration along contour: branch cut problem?

Context Following this question on path integrals in the complex plane, having defined again a numerical and symbolic integrator along a path as ...
10
votes
3answers
399 views

The numerics of FresnelS[]

Bug introduced in 12.1 or earlier and persisting through 12.1.1 or later [CASE:4615361] Note: A worse problem existed in 12.0 for inputs greater than 8 and of ...
10
votes
1answer
402 views

Evaluating Lauricella functions in Mathematica?

Consider the Lauricella functions. The Mathematica documentation does not contain anything regarding Lauricella. Is there any known way (e.g. an unofficial package) ...
10
votes
2answers
292 views

Integration of Booles and Gaussians in high dimensions

Context As a follow up of this question, I would like to predict the connectivity of the so-called cosmic web in arbitrary dimensions. The connectivity $\kappa$ is defined as the number of ridges ...
10
votes
1answer
838 views

Circumvent NDSolve::bdord: error for 1-D Euler Equations

I attempted to use NDSolve for the 1-D isentropic unsteady flow equations with low subsonic inflow velocity and prescribed inflow total enthalpy; along with a non-...
10
votes
1answer
152 views

Does Overflow[] poison session for N?

Summary: once Mathematica hits an overflow error, N[] appears to break for even simple calculations. RealDigits[N[Sqrt[2]-1,10^8]]; I was impressed that ...
10
votes
0answers
134 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 ...
9
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 ...
9
votes
3answers
894 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: ...
9
votes
4answers
731 views

Numerical instability in cosh and sinh - integral functions [duplicate]

I'm trying to calculate the function: CoshIntegral[x] Sinh[x] - Cosh[x] SinhIntegral[x] Unfortunately Mathematica seems to hit a point (x~20) and things become ...
9
votes
3answers
314 views

Numerically evaluating parameter derivatives of a hypergeometric function

I am unable to obtain the numerical value of the derivative of the hypergeometric function. Please note that the (2,4,0,0) is the derivative with respect to the first and second argument ...

1 2 3
4
5
36