Questions tagged [numerics]

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

Filter by
Sorted by
Tagged with
4
votes
1answer
76 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
35 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
78 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 \...
3
votes
2answers
164 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
54 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
746 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
66 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
385 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
205 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
89 views

An example of symmetric, real entry matrix with non-real eigenvalues, according to Mathematica. Is this a bug?

The following matrix is symmetric and all entries are real, ...
4
votes
2answers
527 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
28 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
39 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
92 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
79 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
261 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
47 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
147 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
74 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
239 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
100 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
719 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
65 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
55 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
99 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
79 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
119 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
48 views

Plotting numerical solutions (multi solutions)

I am trying to plot the solutions of this equation. ...
3
votes
1answer
54 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
96 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
68 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?
0
votes
1answer
64 views

Find area under real part of complex curve without numerically integrating

I have a function defined within the domain 0<=x<=2*Pi. f = Cos[x] * (a - 1 - r*Cos[x])^1.5 on the domain: ArcCos[(a-1)/r] < x < 2*Pi-ArcCos[(a-1)/r] f = 0 elsewhere 'a' and 'r' are ...
0
votes
0answers
50 views

FindMinimum is running too slow

For defined a function h[x_?NumericQ], I can get a plot of the function from Plot function in about seven seconds. But when I ...
0
votes
0answers
116 views

Why can't Nsolve find the solutions for my equations?

I have a problem using NSolve in my Mathematica code. In my Code NSolve should find a value for qw, but it won't. The strange ...
2
votes
3answers
72 views

Exponentials don't cancel numerically [closed]

I'm trying something essentially like N[Exp[-x]*(D[Exp[x*y^2], y] /. y -> 1)] After differentiation and y -> 1 there is ...
0
votes
1answer
63 views

DFT and continuous Fourier transform gives different result? [closed]

I am working on the inverse Fourier transform of $\frac{\sqrt{|k|}}{i(|k|-\omega)-\Gamma}$ with $\omega=100, \Gamma=1$. For continuous Fourier transform, I get the following result: ...
2
votes
3answers
293 views

N[…, 5] does not returns what I expected

I have this ...
5
votes
2answers
154 views

How to preserve normalization in NDSolve?

I have a probability density function: $P_{init}(x)=\exp(-(x-x0)^2)/\sqrt{\pi}$. I am trying to use it as the initial condition for the following partial differential equation: ...
4
votes
1answer
86 views

Numerical continuation methods for bypassing a singularity when integrating an ODE

Here is the ODE I want to numerically integrate, odey=-l (1 + l) R[y] + (k - y) (-2 Derivative[1][R][y] + (k - y) (R^\[Prime]\[Prime])[y]) If we rearrange it in ...
3
votes
5answers
209 views

Calculating the Dottie number using an infinite series

The Dottie number is the solution to the equation $\cos(x) = x$ It is approximately equal to $0.739085133215160641655312.$ This number can be expressed analytically in the following form (see this ...
3
votes
2answers
87 views

Legendre polynomials that evaluated with huge difference

I'm dealing with Legendre polynomials, involving the first kind, second kind, and the associated ones. However, I found this: ...
0
votes
0answers
104 views

How can I solve this KdV equation numerically by Mathematica?

I have been trying to solve the following Korteweg-de Vries (KdV) equation using NDSolve but nothing went right! \begin{align} 6 U_{t} + \frac{9}{2} U_{xxx} + 9 U U_{x} - 6 a U_{x} = 0\\ U_{...
1
vote
3answers
178 views

NDSolve fails at the regular singular point of a second-order ODE

Here is the ODE I want to numerically integrate, odey=-l (1 + l) R[y] + (k - y) (-2 Derivative[1][R][y] + (k - y) (R^\[Prime]\[Prime])[y]) If we rearrange it in ...
0
votes
1answer
91 views

NDSolve and interpolating function

What could possibly went wrong in my code? Basically, I am solving the differential equation $\textbf{ode}$ using $\textbf{NDSolve}$. But mathematica says, NDSolve::mxst: Maximum number of 10000 steps ...
0
votes
0answers
39 views

Optimising the NSolve

Suppose I have the following list of rational functions, ...
1
vote
0answers
96 views

Help in minimizing a cumbersome function

I'm trying to minimize a function in order to find a slope critical heigth on a solope stability analisys. The functions taken from (Chen 1975) are the following: I added all the equations to mma but ...
0
votes
0answers
46 views

Devise a compact storage mode

I am writing a code for solving a symmetric band matrix by Cholesky decomposition. I need to store the matrix by defining only the non-zero diagonals of the matrix not the full matrix with band size $...
3
votes
1answer
96 views

Approximating decay rate of an amplitude and frequency of an oscillating function

I have an InterpolatingFunction constructed from a discrete set of values obtained by numerical methods. Let's denote it $f(x)$. The function demonstrates an ...