Questions tagged [numerics]
Questions on the numerical functions of Mathematica, implementing numerical methods and numerical computing with Mathematica.
2,018
questions
5
votes
5
answers
620
views
How to solve the minimum value of a function without analytic expression?
The analytic expression can be obtained for f.
f = Integrate[AiryAi[x], x]
-((x (-3 Gamma[1/3] Gamma[5/3] HypergeometricPFQ[{1/...
0
votes
0
answers
22
views
How to plot a function that depends on a solution to a numerical equation?
Consider a function
H[q(t),r(t)] = (1/2)(f[r(t)]-f[q(t)]),
where f(x) is known, r(t) depends on q(t), and q(t) is a solution of a numerical equation.
Question: How do I plot H(t)?
0
votes
1
answer
52
views
Representing a number in r0 + r1 E + r2 E^2 form
Let E be the base of natural logarithm 2.71...
A Sequence S[n] is believed to converge to a ...
0
votes
1
answer
120
views
NIntegrate: slow convergence error and speed efficiency [closed]
I am trying to produce a plot but NIntegrate is very slow and making a number of warnings, I have used UnitStep[] to keep the ...
6
votes
2
answers
661
views
NDSolve very slow on 2D heat equation
I am trying to solve the 2D heat equation
$$
\begin{cases}
u_{t}-u_{x x}-u_{y y}=f \\
u(0, x, y)=\sin (2 \pi x) \sin (2 \pi y) \\
u(t, 0, y)=0 \\
u(t, x, 1)=0 \\
u_{x}(t, 1, y)=2 \pi e^{-t} \sin (2 \...
0
votes
0
answers
46
views
How to increase the precision of numerical derivatives?
I need to make sure about precision of numerical derivatives in my calculations. I use finite element method to obtain a wave function, then I take derivatives of this numerical wave function to get ...
0
votes
0
answers
61
views
Implement of Euler Method of Parabolic PDE
I'm experimenting with different schemes for numerically solving PDEs in Mathematica. I use NestList to implement the Euler Method for 1-D PDE, the code is concise:
...
0
votes
0
answers
40
views
Finite Difference and LinearSolve
I have two nonlinear second order coupled boundary value ODE whose dependent variables are $u(x)$ and $z(x)$. I want to solve it using the Relaxation method (Finite-Difference), however, I can't ...
0
votes
0
answers
35
views
0
votes
1
answer
46
views
Why does an error occur in one case, but not in the other, and how to fix it?
Why do errors appear for this Kx[11, 15] when this Kx[11, 14] is considered without error? How to fix it?
...
6
votes
2
answers
76
views
How to pass solution of ParametricNDSolve to NSolve
I am taking here example ParametricNDSolveValue problem from documentation
...
1
vote
1
answer
45
views
Finding numerically roots of equation over region
I'm trying to solve the following numerical problem:
I have a function of 2 variables in some rectangular region, the function is computed numerically with some moderate time cost (solution of linear ...
0
votes
1
answer
51
views
Make a list for n from 2 to 10 of array plots for x and y up to 50 x^y mod n [closed]
Table[ArrayPlot[Mod[x, y, n]], {n, 10}, {x, 1, 50}, {y, 1, 50}]
expected answer
[
2
votes
1
answer
57
views
Finding the root of a scalar function of 3 variables which is a an interpolation of data?
Dear Stackexchange community, I am puzzling the following question:
I have energy values on a three dimensional grid. More precisely, I have the solutions from a band structure calculation on a three ...
1
vote
2
answers
160
views
Accurate NDSolve for PDE with NIntegrate Functions
I have a function $A(c)$ which is defined by an integral. I wasn't able to solve it analytically, and therefore defined $A(c)$ using NIntegrate:
...
5
votes
3
answers
234
views
How can I transform the list into the required form?
I have the list:
List1={{7, {-0.91, {a -> 0.61}}}, {10, {-1.41, {a ->
0.44}}}, {12, {-2.00, {a ->
0.35}}}, {15, {-2.69, {a -> 0.28}}}}
I ...
0
votes
1
answer
63
views
Why, if you write the expression in the form of two functions, does the code stop working?
I would like to find the minimum of the function EER[a, v] using parallel computing.
If I write the code like this, it works:
...
3
votes
1
answer
195
views
Coiling of flexible ropes (nonlinear BVP of ODEs with 10 unknown functions and 2 parameters)
I want to solve this ODEs with NDSolve, but it fails. The $F$(F), $\gamma$ (γ) is the given ...
1
vote
1
answer
144
views
Why is there an error in one case and not in the other?
Why does the error occur for P[34, 14] whereas for P[33, 14] has no error? How to get rid of this error?
...
1
vote
0
answers
64
views
Why does the minimum eigenvalue sharply decrease when the number of basis functions increases from 37 to 38 and more?
I have the following Hamiltonian: H = -1/2 * Laplacian -1/r - 2 * r/5 * (Exp[-r * 1.6] + Exp[-r * 3.1])
I'm trying to find the minimum eigenvalue of this Hamiltonian using the matrix method. As basis ...
2
votes
2
answers
158
views
NIntegrate gives the wrong result
I have tried to calculate an integral of a function numerically using NIntegrate, but sadly it seems like I do not get the correct result from it.
The function $\...
14
votes
1
answer
257
views
What Reap/Sow tricks do you use?
I admit that I have been reluctant to use Reap and Sow for years and that I used it only when I had no choice with ...
1
vote
1
answer
128
views
Eigenvalues of Coulomb potential
As it turned out in the previous question (Eigenvalues of A/r^2 + B*r^2 potential), in order to find the energies by the matrix method, it is necessary to have a complete set of basis functions. @...
3
votes
1
answer
37
views
How to troubleshoot NIntegrate non-numerical error?
I am trying to evaluate a 2d integral (denoted as x and y here) with a function that involves a numerical integral at each point....
0
votes
1
answer
46
views
Is the equality correct? [closed]
Is the equality above correct where q satisfies |q|<1 ? If it is, how to prove it?
2
votes
1
answer
104
views
Eigenvalues of A/r^2 + B*r^2 potential
I would like to find the energies of a system in a matrix way. The system has the following Hamiltonian:
H1 = -1/2Laplacian +(A1/r^2)+(B1r^2)
I use radial functions as basis functions: Psi1[r_, n_] =...
1
vote
1
answer
216
views
Why Wolfram 12.1 not calculated? [closed]
Why doesn't scientific software count,
...
0
votes
1
answer
113
views
Why do different calculations give different eigenvalues?
I find the eigenvalues of the Hamiltonian in two ways - numerically and matrix . Why do different calculations give different eigenvalues?
The Hamiltonian is H = -1/2*Laplacian -(2/r)
It can be seen ...
1
vote
1
answer
59
views
Equality contraint violated with NMinimize
I am attempting to numerically optimize a function of only 2 parameters k, θ. There are two inequality constraints (1 each on k ...
3
votes
6
answers
612
views
How to ask Mathematica to compute the given sum of the differences of the numbers of the given two sets?
I have two sets of real numbers, say,
set1= {b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11}
...
3
votes
2
answers
112
views
1D ODE: singularity or stiff system suspected
I'm trying to solve the nonlinear Poisson-Boltzmann equation in a cylindrical geometry. In this example I am surrounding a central charged rod with a neutralizing shell of charge, although I get the ...
1
vote
2
answers
103
views
NMinimize keeps returning Indeterminate for well defined function
I am attempting to numerically optimize a function of only 2 parameters k, \[Theta].
The function is well-defined and the constraints are simple. However, the ...
4
votes
1
answer
125
views
How to know the minimal mesh size of NIntegrate?
Sometimes it is necessary to know the discretization mesh size in numerical integration. But since NIntegrate is a complicated composition of various algorithms, it ...
1
vote
2
answers
122
views
Trying to apply numerical method with Do
I am trying the following scheme to learn to implement an iteration using Do loop. I tried to implement the same method using for loop but with same errors. I, therefore, turned to the Do loop to ...
2
votes
1
answer
143
views
How to avoid infinities in the following example?
The task
Consider a decaying particle traveling along some axis $x$, with the differential probability to decay given by the Poisson distribution:
$$
\frac{dP_{\text{decay}}}{dx} = \frac{\exp[-x/l_{\...
3
votes
2
answers
163
views
Non-linear integro-differential equation with infinite domain of integration
$$I(t)=\frac{dy(t)}{dt}+\int_{-\infty}^t dt'\left[\sin\left(\frac{y(t)-y(t')}{2}\right)f(t-t')-\sin\left(\frac{y(t)+y(t')}{2}\right)g(t-t')\right]$$
with $y(t\leq 0)=0$ and $I(t)=I_0\Theta(t)$ with $\...
0
votes
0
answers
61
views
How to get a result for some values of parameter H
This is my code.
...
1
vote
0
answers
106
views
How to simplify/express the given number in a compact rational form?
I have the given number; using N[numb], I can find its approximate value but I want to simplify it in a short compact rational form (containing a trigonometric ...
1
vote
0
answers
49
views
Mathematica incorrectly claims an infinite sum doesn't converge
When I compare the output of the following commands I get contradictory results:
Sum[BesselJ[k, 1], {k, 0, Infinity}]
NSum[BesselJ[k, 1], {k, 0, Infinity}]
The ...
10
votes
2
answers
267
views
How to monitor the progress of LinearSolve?
I am trying to do something like
...
2
votes
2
answers
76
views
How to speedup comparison in the following example?
I have the following problem: I would like to generate random values of some variable $z$ obeying some distribution, but simultaneously within the interval zmin<...
1
vote
1
answer
67
views
Speed up summation of many inverse matrices
Physical background
I am trying to write a code that computes the Green function of a system, given the Self energy $\hat{\Sigma}_n$, a list of Matsubara frequencies $z_n$ ($n=1,...,N_{Mats}$) and the ...
1
vote
1
answer
57
views
Strange behaviour of IntersectingQ
I wanted to check whether two lists of complex numbers have an element in common and stumbled upon this rather strange behaviour of the function IntersectingQ. If I ...
0
votes
0
answers
51
views
How to solve a delay partial differential equations numerically?
A set of special partial diffential euqations like this:
$$\dot{O}_x=\textrm{i}\cos^2(\tau)\partial_\tau O_y+\alpha O_x(\tau=0,t)O_z-\frac{O_x}{T_2}$$
$$\dot{O}_y=-\textrm{i}\cos^2(\tau)\partial_\tau ...
1
vote
1
answer
80
views
Inconsistent results solving system of equations with FindRoot
I have been trying to solve the following problem (Is basically a physics problem: an expansion of equations of state up to 1st order of the order parameter in order to solve for the critical ...
1
vote
2
answers
240
views
How to prevent Mathematica from rounding some PDF values to 0?
Dear Mathematica community,
I'm having a problem with the PDF function for the hypoexponential distribution. Specifically, Mathematica returns 0 as soon as the value is very small. Below is an example:...
2
votes
0
answers
76
views
Z-eigenvalue problem
I am interested in solving an $N-$dimensional $Z-$eigenvalue problem, which schematically takes the following form
$$
\sum_{b=1,c=1}^{N}T_{abc} X_b X_c=\lambda\,X_a\quad \text{with}\quad \sum_{a=1}^...
1
vote
2
answers
89
views
Smooth out numerical fluctuation at known point
I have the following function
...
0
votes
1
answer
65
views
How to avoid General::munfl errors?
Let's have a look at a following system of equations:
...
1
vote
0
answers
76
views
Kahan Compensated Summation
Is there an example/library that implements Kahan summation in Mathematica for matrix-matrix/vector-matrix multiplication?
Having some trouble adapting something like this Compilation of Total with ...