Tagged Questions

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

learn more… | top users | synonyms (1)

0
votes
1answer
174 views

find derivative with defined function

s[a_, b_] := NDSolve[{y''[x] == y[x] Cos[x + y[x]], y[0] == a, y'[0] == 1}, y, {x,0, b}] I need to find the minimal of $\int _1^by[x]^2$ in the region ...
-4
votes
1answer
206 views

findroot, derivative in defined functions

I apologize for my unclear question, I will write it in a more detailed way. I first define: ...
4
votes
2answers
428 views

Numeric calculation of Hessian

I want to calculate the Hessian matrix for a function that can only be evaluated numerically. So far, I have the following (where f is just for testing): ...
0
votes
0answers
151 views

Assigning numerical values to constants results in complex coefficients in Equations of Motion

I am using Mathematica to get the Equations of Motion (EOM) for a mechanical system (using Lagrangian Mechanics). While I get the EOM in symbolic form, on introducing the following code for assigning ...
1
vote
1answer
165 views

FindRoot equation-variable mismatch

I cannot figure out why FindRoot doesn't work and returns this error: The number of equations does not match the number of variables in ... My problem: drawing ...
2
votes
1answer
134 views

Strange behavior when replacing variables by numerical values [duplicate]

I have a rather complicated function with parameters {a, b, c, d, e, f, k}, and I'd like to know its behavior as a function of k alone given other parameters, so I try the following code: ...
2
votes
1answer
256 views

Problem with Covariance Matrix Output in NonlinearModelFit

I am running NonlinearModelFit based off of some simulated data and trying to fit to a function with more than one parameter. Eventually, I would like to fit to 5 ...
3
votes
1answer
254 views

How can I deal with a non-numerical value for a derivative at $t = 0$ when using NDSolve?

I want to solve two coupled equations with NDSolve, ...
6
votes
1answer
1k views

Mutual Information involving two matrix states

I basically retrieved the following technique of evaluating the mutual information involving two matrices from this site at http://bmia.bmt.tue.nl/People/BRomeny/Courses/8C080/default.htm The ...
0
votes
2answers
88 views

Generating equally distributed voxel points based on a given point

I have a list of seed points that each of them indicates the bottom-left value of a voxel. In order to improve the accuracy of my function, I need to equally sample my points and apply my functions ...
-1
votes
1answer
261 views

Help in NIntegration Methods - Takes too long, why?

I have this code. It is a triple integral, and using the automatic method gives me a wrong answer for $T=0.1$ (the correct answer is $5.44$, while I got $3.73$ ). I've tried to change the integral ...
17
votes
2answers
2k views

How to fit 3 data sets to a model of 4 differential equations?

I'm a biologist and a newbie in Mathematica. I want to fit three data sets to a model consisting of four differential equations and 10 parameters. I want to find the parameters best fitting to my ...
-1
votes
2answers
287 views

Performance of numerical optimization with triple integral [closed]

I'm trying to solve a numerical optimisation that looks something like this: ...
3
votes
2answers
317 views

Speed of convergence for NIntegrate

I'm trying to optimise numerically a function that entails computing the expected value of a truncated trivariate normal distribution and this is taking extremely long -I also get warned about ...
1
vote
1answer
130 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 ...
4
votes
0answers
777 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 ...
0
votes
1answer
215 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 ...
7
votes
1answer
1k views

Minimization by Nelder-Mead

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 ...
4
votes
2answers
434 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 ...
5
votes
1answer
78 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 ...
44
votes
3answers
1k 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: ...
3
votes
2answers
273 views
5
votes
1answer
208 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 ...
3
votes
1answer
530 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 ...
9
votes
1answer
1k views

Computation of Hankel Transform using FFT (Fourier)

To address circular symmetric cases of 2D Fourier Transformations the so called Hankel Transform can be applied (for a detailed derivation of the relation between the 2D Fourier transform and the 1D ...
0
votes
0answers
64 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 ...
1
vote
1answer
114 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 ...
5
votes
0answers
120 views

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

I want to solve the following differential equation numerically: \begin{equation} 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) \end{equation} ...
1
vote
3answers
87 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 ...
1
vote
3answers
306 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 ...
2
votes
0answers
171 views

Speeding up a numerical constrained quadratic optimization

I'm trying to solve a quadratic optimization problem in 35 variables, $\vec{α} = \left< α_1, \ldots, α_{35}\right>$: $$ \begin{aligned} &\operatorname*{maximize}_\vec{α}&&1.0\cdot ...
14
votes
1answer
251 views

How to create internally optimized expression for computing with high WorkingPrecision?

I have large dataset and need to fit rather complicated function on it with different values of one of its parameters (this parameter must be fixed in every fit). I use the ...
2
votes
2answers
317 views

Strange Behavior of NDSolve

I am trying to evaluate the following ODE numerically: ...
2
votes
0answers
39 views

NIntegrate/NSum with parameters [duplicate]

I'm trying to calculate a continuous integral within a discrete integral. Something similar to this (yet more complex): ...
0
votes
1answer
223 views

DAE - varying initial conditions

I want to solve a DAE-system and I want to vary more than one initial conditions and to manipulate them. I looked here: Putting NDSolve into ParametricPlot But it does not work: ...
4
votes
2answers
182 views

Numerical sum does not give consistent results

Consider the function ...
7
votes
0answers
431 views

Numerically solve 2nd order differential equation with singularity

Consider a second order differential equation with a potential that diverges at some generic value in the variable. For example: $$-y^{\prime\prime}(s)+\frac1{\mathrm{cn}{(s\mid k^2)}}y(s)=0$$ where ...
18
votes
3answers
383 views

How to flush machine underflows to zero and prevent conversion to arbitrary precision?

I'm working on some pretty intense computation in Mathematica; when my code started running slowly, I tracked the source of the problem to Exp[]. I need to ...
37
votes
1answer
924 views

How to compare power towers in Mathematica?

First I tried it directly, but it overflowed: ...
9
votes
1answer
469 views

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

I am trying to evaluate this integral numerically $$ \int_0^{\infty } J_0(q R) \tanh(q) \, \mathrm{d}q $$ for large values of $R$. This makes the integrand oscillate more quickly and Mathematica ...
1
vote
1answer
224 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 ...
1
vote
1answer
360 views

why there is a small imaginary part [closed]

I encountered a problem. I have a eigenvector eigvsI[1] ...
4
votes
1answer
131 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 ...
1
vote
0answers
264 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 ...
3
votes
0answers
393 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 ...
3
votes
1answer
539 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: ...
17
votes
1answer
1k 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 ...
2
votes
1answer
740 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: ...
3
votes
1answer
115 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 ...
1
vote
2answers
500 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 ...