Tagged Questions

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

167 views

FindMinimum gives wrong solutions inside a loop

I have a density function $\rho(r,z)$ and I want to calculate the minimum distance $d_{min} = \sqrt{r^2 + z^2}$ from the center (0,0) in which $\rho$ becomes negative. The easiest way is to find where ...
1k views

Numerically solving system of partial differential equation

I am trying to solve a system of partial differential equation with boundary conditions. But I got an error message saying NDSolve::icfail: Unable to find initial ...
310 views

Gram-Schmidt process with Hermite functions on [-1, 1]

Denote by $h_n$ the $n$-th Hermite function. $$h_n(x) = \frac{(-1)^n }{\sqrt{2^n n! \sqrt{\pi}}} \mathrm{e}^{\frac{x^2}{2}} \frac{\mathrm{d}^n}{\mathrm{d} x^n} \mathrm{e}^{-x^2}$$ I am trying to ...
2k views

Finding a global minimum for this problem (non-linear optimization by the Nelder-Mead downhill simplex method) may not be possible, but by finding local minimum, I am expecting the value of the ...
751 views

Why doesn't FindRoot work correctly?

I'm trying to find the roots of the following equation: I need to find λs for different values of ξ. I know that for all ...
88 views

Why is NHoldFirst not propagated to symbolic derivatives?

I encountered a nasty problem that N cannot evaluate expressions containing a symbolic Derivative of a multi-parameter function ...
2k views

When I can 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-...
300 views

How can I prove an equation has a certain number of real roots?

I have this code ...
371 views

Accurately evaluating the hypergeometric function

As part of another problem, I am working to evaluate hypergeometric functions such as Hypergeometric2F1[1, 1, n, -1] for large $n$. I am hoping to obtain at ...
1k views

Monitoring the Evaluation of NDSolve: time to finish estimation

My problem is quite simple: I run a NDSolve with a system of many ODEs, a calculation that will run for many hours, and I would like to know the progress of the ...
3k views

Computation of Hankel Transform using FFT (Fourier)

To address circularly symmetric cases of 2-D Fourier Transformations, the so-called Hankel Transform can be applied (for a detailed derivation of the relation between the 2-D Fourier transform and the ...
71 views

Initializing Minimization [duplicate]

I am trying to implement a model predictive control scheme in Mathematica, e.g. I optimize input sequences by predicting future outputs. So every time I call the cost function it will simulate the ...
131 views

Set theoretic operations on sets of real numbers

I have two pieces of code that produce a bunch of real numbers, say $A$ and $B$ respectively. (It is not relevant to the question, but $A$ consists of eigenvalues of the Hamiltonian of some physical ...
170 views

Numerical solution of Schrödinger-type equation in Mathematica [duplicate]

I want to solve the following differential equation numerically: $$i\partial_{t}\psi(r,t)=\left[-\frac{\Delta}{2m}+g\left|\psi(r,t)\right|^{2}+V_{d}(r,t)\right]\psi(r,t)$$ ...
93 views

How to calculate solution for each variable automatically

Here I have one problem how to calculate x for each y. In this form code doesn't work ...
651 views

Making a calculation with high precision

I would like to make the following calculation: 1/Sqrt[1 - (150^2 10^(-4))/(9 10^16.)] - 1 Mathematica 8 returns 0. The result is obviously not 0, but my ...
327 views

266 views

Why is arithmetic faster for inexact arithmetic?

I have been trying to compute eigenvalues of a rather sizable matrix A, about $500 \times 500$ (but sparse). I asked Mathematica to compute ...
1k views

why there is a small imaginary part [closed]

I encountered a problem. I have a eigenvector eigvsI[1] ...
198 views

Minimize failing on a polynomial

Calling: Minimize[{-0.4877 - 0.1190 r^2 - 0.1885 r^4 + 2.9703 z - 0.5531 z^2, 0 <= z <= 3.5 ∧ 0 <= r <= 1.75}, {r, z}] returns ...
431 views

Adapting NDSolve to 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-...
767 views

FindRoot gives a wrong solution which obviously should not be there

I got stuck on FindRoot and I didn't see any similar problem posted, so let me explain what I am trying to do and what problem I meet here. I try to find roots of a particular function, which in the ...
1k views

NDSolve for a large system of simple ODEs

I am solving a system of many (more than 100) ODEs. It is the kind of standard rate equation encountered in semiconductor physics. Here is the system: ...
2k views

Optimizing a Numerical Laplace Equation Solver

Laplace's Equation is an equation on a scalar in which, given the value of the scalar on the boundaries (the boundary conditions), one can determine the value of the scalar at any point in the region ...
2k views

Plot FindRoot for non-trivial function

I would like to plot the results of FindRoot over certain range of inputs. I tried to do this with the code: ...
165 views

Find point at which equation stops having roots (if it exists)

I am interested in the roots of this function: f[M_, b_] := 1 - (2 M Gamma[2, 0, (1/M + b M)/Sqrt[b]])/(1/M + b M) for fixed values of b. In particular I want ...
1k views

How can I use FindRoot on an expression from NDSolve?

I have a second order ODE that I can only solve numerically using NDSolve, but I then need to use the solution in FindRoot and am running into errors. A simplified but analogous problem is the ...
241 views

FindMaximum inconsistency

The code below seems to work for n<11. But for n=11, and above, it outputs newa then just outputs "beep" sound. WhyTheBeep says "The kernel Local has quit (...
753 views

How to guess initial complex value for FindRoot

I have to solve a transcendental equation for a parameter, say $\beta$. Now, the $\beta$ has a range from $ik$ to $k$ where $i$ is the usual imaginary root $\sqrt{-1}$ and $k$ is a real number. ...
838 views

Tutorial for basic numerical methods for PDEs

I'm afraid this is probably not going to be a "good" question, but I'd like to use Mathematica to learn about basic numerical schemes for solving pdes. For example, I'd like to compute the solution of ...
344 views

Numerical Error with Large Matrices

I am writing a Finite Element Analysis program in Mathematica. The code involves handling a large matrix with large entries. I get an error when I try to use Mathematica's "LinearSolve" to solve a ...
266 views

Computing the minimum distance in a contour plot

I have the following Mathematica code ...
1k views

Numerical partial derivative

For a one-variable numerical function, it's simple to calculate the derivative at a point with Derivative as Szabolcs has pointed out before: ...
348 views

Strange behaviour of PolyLog Function

I discovered some strange behaviour of the PolyLog[] Function in Mathematica which seems to me like a bug in the function implementation. It looks like ...
510 views

What is the correct way to use NIntegrate inside the FindMinimum function?

I'm having minor issues with the FindMinimum function when using NIntegrate inside. The functions work perfectly well but I get ...
293 views

How can I name “a[[i]]” the parts of Table “a”? Or how to make Table “a” grow inside FindMinimum?

Let's say I want to minimize a function that uses a Table named a with the Conjugate Gradient Method of ...
639 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: ...
2k views

NDSolve does not respond

For some sets of constants, NDSolve gives me true solutions, but when I try for example, T = 1/(2*2200), Mathematica does not respond. What can I do? The code below ...
234 views

Alleviating a bottleneck involving a function call with symbolic derivatives

I have a bottleneck problem involving a function call with symbolic derivatives. I don't have much experience with Mathematica (or any dynamic language) and I'm certain that the way I've set this up ...
312 views

Mathematica 7: Problems when evaluating Fourier inside a ParallelTable

after I got such a great response for my first question on this site, I'm very encouraged to asked my second one! So here it is, very generally: To speed up a "row-wise" (i.e. 1D) operation on a ...