Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [numerics]

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

6
votes
2answers
133 views

Sorting upon the first element of a nested list and show that as numerical values

I wish to sort the below list upon the first elements: ...
0
votes
0answers
13 views

SystemException[“MemoryAllocationFailure”] with long evaluation involving FindRoot

I had earlier posted my code in a previous question, but I am reposting my code here: ...
1
vote
0answers
33 views

Exponential distribution and numerical errors?

I am working on the measure of a Curie Weiss model over a lattice $$ \mu[m] = \frac{e^{\beta N (hm + m^2)}}{\sum_z e^{\beta N (hz + z^2)}}\binom{N}{\frac{(1-m)N}{2}}2^{-N} $$ where $m\in\{-1,-1+2/N,\...
0
votes
0answers
33 views

FindRoot for a transcendental function (PolyLog)

I am trying to solve an equation involving polylog using FindRoot, I am not sure how to give the initial guess as I want to solve the equation for a variety of parameters. Here is my code: ...
0
votes
1answer
31 views

How to keep the numerical integration when a event occurs?

I'm numerically integrating the following system, f[r_] = 0.904965 - (1 + 12.7028/r^2) (1 - 2/r) dϕdλ = 1/r[λ]^2; eqc = r'[λ] == Sqrt[f[r[λ]]/(dϕdλ^2)]; with the ...
11
votes
1answer
660 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 ...
3
votes
2answers
160 views

Underflow error General::munfl from E^x instead of Exp[x]

In contrast to earlier versions, Mathematica 11.3 and 12.0 generate lots of underflow errors from my code, e.g. ...
2
votes
1answer
52 views

Creating a mesh from a very thin layer

I have the following code which works just fine: ...
2
votes
1answer
43 views

Find x at a given t and f(x,t) == constant from a system of coupled PDE

Is it possible to find the speed of a moving front (produced by the below code) in which modulating beta changes the speed of the front? Basically, I am trying to map the x-values of f(x,t)=0.5 ...
0
votes
0answers
26 views

Changing a Constant Based on Certain Radius

I'm trying to change my Mu based on the size of my spherical radius but cannot seem to get the code right. I've tried numerous ways but end up either with only one Mu (ex. Mu=21) in the end or code ...
3
votes
1answer
198 views

Solution of Burgers equation with some initial data

Consider the Burgers equation $$\partial_t u + \partial_x\left(u^2/2 \right) = 0, \quad u(0, x) = u_0(x).$$ eq = D[u[t, x], t] + D[u[t,x]^2/2, x] == 0 How ...
1
vote
1answer
107 views

Numerical simulation for density of strings in a ball

I am trying to numerically reproduce the Mathematica result for the density of strings in a sphere as explained here. The program is to generate random, uniformly distributed pair points on a unit ...
1
vote
1answer
42 views

How to plot even function without noticeable asymmetry

I am trying to plot a series of functions. But the picture is looking a bit asymmetric despite that the functions are even. If I try to use Geometricaltransformation function to reflect the plot that ...
2
votes
1answer
76 views

Correct syntax for working precision in functions version 12

I just recently updated from version 11.2 -> 12...there apparently are quite a few changes since 11.2. $\unicode{952}\unicode{960}$ One being how version >11.3 deal with numbers that approach zero. ...
10
votes
2answers
803 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 ...
4
votes
1answer
68 views

Improving Speed of Binomial and Multinomial Random Draws

A number of users have discussed the speed of Random number generation in Mathematica. The Binomial and Multinomial random number generators in Mathematica are fast if multiple draws are needed for ...
0
votes
1answer
34 views

NDSolve outcome depends on system size?

I tried to solve a simple wave equation numerically and plot the result within the time range t=0...1. Now when I change the tmax in the NDSolve the outcome of my plot (I don't change anything else ...
0
votes
0answers
73 views

Numerical methods to solve an ODE with discontinuous coefficients

Consider the ODE $$\partial_t \Phi(t,x) = \mathbf b(\Phi(t,x)), \qquad t \in [0,T], \quad x=(x_1,x_2) \in \mathbb{R}^2$$ $$\Phi(0,x) = x, \quad x \in \mathbb R^2,$$ where $\mathbf b = (0,\chi_{\{x_1 \...
-1
votes
0answers
28 views

Warning: Reduce was unable to prove that the solution set found is complete

I am trying to solve the below equation, but there is a warning " Warning: Reduce was unable to prove that the solution set found is complete" . Could somebody please introduce a method for ...
3
votes
2answers
161 views

NIntegrate on a solution of a matrix ODE

I've seen similar questions on this site but somehow the solutions there didn't manage to solve my specific problem. I have a function mat1 that takes a square $n \times n$ matrix G, and some final ...
0
votes
0answers
52 views

Plot BV functions with singular derivatives in multiple space dimension

In 1-dimensional setting, two key examples of $BV$ functions (of bounded variation) $u: \mathbb R \to \mathbb R$ are the Heaviside function, whose derivative is the Dirac delta concentrated at $0$. It ...
3
votes
2answers
740 views

How to evaluate this function?

I’m trying to evaluate y[t] = InverseFunction[ NIntegrate[Sqrt[2]/( -8+Exp[y]+2Exp[-y]), {y,0,t}]] Some of the problems I’m facing, is that i’d like to get the ...
1
vote
1answer
63 views

How to write mathematica code for Newton's Forward Difference Formula?

I want to write the Newton's Forward Difference Formula in mathematica: http://mathworld.wolfram.com/NewtonsForwardDifferenceFormula.html I know there many functions to interpolate data in ...
5
votes
2answers
365 views

Numerical methods to solve a continuity equation

What numerical methods can be used to study the initial value problem for the continuity equation where $ u = u(t, x) $ $$ u_t + \nabla\cdot(\boldsymbol b u) = 0, \qquad t \in [0,T], \quad x=(x_1,x_2)...
3
votes
1answer
190 views

Boundary conditions are not satisfied with NDSolve

I want to study the time evolution of a small perturbation around the static solution of the following Wave Equation $$ -\partial_t^2 v(t,r) + \partial_r^2v(t,r) + \frac{2}{r}\partial_r v(t,r) = \...
0
votes
1answer
88 views
4
votes
1answer
417 views

How to prevent mathematica rounding extremely small numbers to zero?

I have a function that, while the maths itself is unimportant, at certain values it results in a very large number multiplying a very small number. E.g. 10^450000 * 10^-449998. As you can see, this ...
0
votes
0answers
24 views

Maximum likelihood method computational details

I am currently using the command FindDistributionParameters to estimate the parameters of a StableDistribution via Maximum Likelihood using Mathematica 11. As there are different MLE methods for ...
0
votes
0answers
38 views

Can I use countroots with an Interpolating Function?

I want to count the number of roots of an interpolating function that is the result of a system of differential equations (that were solved numerically using NDSolve...
0
votes
2answers
67 views

How to find maximum from list or table

I have some result in list form and after I build the graph I have: As you can see on the graph there is a spurious peak at the beginning. So when I tried to find maximum peak, I receive value of ...
1
vote
3answers
73 views

When should one write integer numbers with a decimal?

I often see different solutions where users have taken advantage of how Mathematica handles numbers differently. I.e. when is it appropriate to use a decimal point in a calculation? Can someone ...
6
votes
2answers
242 views

Specific numerical eigenfunctions of Helmholtz equation in 3D for ellipsoids

I am trying to compute the eigenfunctions of an oblate spheroid (a=75 cm and b=60 cm) using Mathematica's FEM package and Chris' answer from here. Specifically, I am looking for eigenfrequencies ...
0
votes
0answers
44 views

Why doesn't SetPrecision give me the precision I ask for? [duplicate]

I'm dealing with a problem requires a precision of 50 digitals after the decimal point. However, I got the following value when doing so: I don't know what's going on here, ain't it 0.09 with other ...
2
votes
2answers
135 views

What is the fastest way of doing one integral in Mathematica?

I want to compute the following numerical integral in Mathematica $\int_0^L dy \int_0^y d \bar{y} f(y,\bar{y}),$ where $f(y,\bar{y})$ is a very complicated function. I show my code below where the ...
2
votes
1answer
68 views

NDSolve solution plugged back into ODE quickly diverges

I have the following ODE with complex $\omega$: $\qquad f(r)\frac{d}{dr}(f(r)\frac{dR}{dr})+(\omega^2-f(r)(\frac{1}{r^2}+\mu^2))R(r)=0,$ and with $f(r)=1-2/r$. I want to solve it starting at $r=2$ ...
6
votes
4answers
224 views

Identifying points in the frontier of a set

Let me start with an example. Let $$\mathbf{A}=\begin{bmatrix}3&1\\2&3\\1&5\end{bmatrix},$$ and let $Q=\{\mathbf{q}\vert\mathbf{q}\in\Bbb R^3_+ \land \sum_i^n q_i=1\}$ and $\alpha=\bigl(\...
0
votes
1answer
55 views

How to solve this equation numerically? [closed]

Two Gaussian functions: f1,f2 of the form f1 = a1*Exp[-t^2/s1^2]. Total area, Atot of (f1+f2) is known. Height of each peak (a1 and a2) is known (experimental ...
3
votes
2answers
95 views

How to solve these ODEs using NDSolve?

I have six odes and I cannot use DSolve. So I tried NDSolve. But it says there may be some errors.The code is such like this: ...
7
votes
2answers
713 views

Does Mathematica reuse previous computations?

I am doing an analysis of experimental results in which I need to repeat the same GaussianFilter hundred of times on different data. As explained in the ...
2
votes
0answers
64 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
67 views

How to avoid getting different results in exponential and trigonometric forms [closed]

I have a complicated numerical complex expression which depends on 6 parameters (Alpha, Beta, Gamma, Delta41, Delta43, Delta). It is too long to put it all here but this is what it looks like: ...
0
votes
1answer
46 views

Problem with {table values} when plotting

I have a Piecewise and Nintegrate both defined with NumericQ. The NIntegrate part of the Piecewise operates when first inserted into a working program, but not when called from inside a table. Their ...
2
votes
2answers
93 views

Numerically stable replacement for generalised incomplete gamma function [closed]

I am looking to replace the generalised incomplete gamma function (which appears in a solution to a problem I've posted about here) with a numerically stable formula involving other functions. This is ...
2
votes
1answer
68 views

How to maximize just with respect two parameters out of four?

There are some posts explaining how do we maximize a function of two parameters with respect to one of those and how to plot the resulting function: Plot a function after taking the supremum with ...
1
vote
2answers
107 views

Evaluation of a hypergeometric function

I am working with functions like f[z_] = Hypergeometric2F1[4, 4, 8, z] Here is a plot of this function over the interval $z \in [0,1]$: ...
2
votes
1answer
45 views

Plotting numerical solutions (multi solutions)

I am trying to plot the solutions of this equation. ...
3
votes
1answer
47 views

Calculation among Gamma functions

I was calculating gamma functions in Mathematica while it does not give me an agreed answer. By definition, $\Gamma[\alpha]=\int_0^\infty t^{\alpha-1}e^{-t}dt$, $\Gamma[\alpha,z]=\int_z^\infty t^{\...
2
votes
0answers
89 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 ...
0
votes
1answer
67 views

Get rid of extra digits [closed]

I have an expression with lots of numbers such as 1.000000002, 2.0000000000001, ... and I would like to automatically set them to 1, 2, ... how can I do that?