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

learn more… | top users | synonyms (1)

8
votes
1answer
148 views

Exp of big negative numbers [duplicate]

I noticed that Exp have a strange behaviour with big negative numbers ...
2
votes
1answer
233 views

How to make Mathematica try harder to perform symbolic comparisons?

(I suspect this question is a duplicate, but I didn't find a sufficiently similar question with an answer to it.) I'm having trouble with comparisons of symbolic ...
0
votes
0answers
177 views

How to implement an implicit iterative method for solving SDEs?

I wish to numerically solve the Black-Scholes SDE as follows $$ \begin{array}{lll} dX(t)&=&\mu X(t)dt+\sigma X(t)dW_t, \ \ \ 0\leq t\leq1,\\ X(t_0)&=&X(0), \end{array} $$ with the ...
1
vote
1answer
150 views

Domain restrictions for NMaximize

I am trying to solve a maximization problem, where my variable can only take a limited number of values. (Probably) the easiest example would be ...
2
votes
1answer
196 views

How can I numerically solve for fractional functions and fractional derivatives?

I would like to plot fractional functions. Say $f=(\sin)^{1/2}(x)$. By that I mean that $f(f(x)) = \sin(x)$. Similarly I can define a half-derivative to be an operator such that $H[H[f(x)]] = ...
3
votes
0answers
103 views

Strange NSum behavior

If I do: NSum[(i + 1)/(i + 2) LegendreP[i, 0] LegendreP[i, 0], {i, 0, Infinity}] I get: 1.25216 If I do: ...
2
votes
1answer
94 views

Use Mathematica to determine the falling law

We have a one-variable equation $\rho(R)$ where ρ = (14656.4+277.526*R^2)/(45.9225+R^2)^{5/2} + 0.370036/(R*(0.25+R)^3) This equations describes the evolution of ...
0
votes
0answers
147 views
7
votes
2answers
398 views

Is there any fast way to solve a quadratic matrix equation in Mathematica approximately?

Let the square nonsingular matrix $M$ is a given convergent matrix. What are the best scalar values for $\alpha$ and $\beta$ (in the real numbers domain), at which the following quadratic matrix ...
4
votes
1answer
104 views

Strange behavior of Mathematica regarding calculation time

Today I witnessed the following strange behavior of Mathematica, when it comes to calculation time involving larger nested lists. The following is the short example that I setup, I am sure one can ...
4
votes
1answer
303 views

Counting the number of operations performed during a calculation

I need to know how can I count the number of operations performed during a calculation of a CompoundExpression. In some of these expressions there are ...
2
votes
1answer
334 views

Crank-Nicolson with NDSolve?

As far as I understand, the Crank-Nicolson method (a.k.a. trapezoidal method) can be expressed as a second order implicit Runge-Kutta method. It's Butcher tableau is: ...
9
votes
1answer
101 views

Apply N only outside a certain function

1 + f[1] // N gives 1. + f[1.] I don't want the argument of f evaluated by N; I ...
1
vote
1answer
156 views
12
votes
2answers
258 views

Why do NumberForm and Round apparently use different tie-breaking methods?

When rounding numbers (for example, rounding a real number to the nearest integer), the "round to nearest" rule is usually used. For example, 1.4 is rounded down to 1 and 1.6 is rounded up to 2. ...
1
vote
0answers
545 views

How to Output Chi-Squared Statistics when using NonLinearModelFit

I am using NonLinearModelFit for some curve fitting and I was wondering if NLM is able to output chi-squared/leastsquared statistics from the best-fit parameters and confidence intervals. From my ...
0
votes
1answer
101 views

Question with ParametricNDSolveValue

When solving the following system: ...
0
votes
1answer
167 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
190 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
362 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
149 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
143 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
133 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
240 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
222 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, ...
4
votes
1answer
786 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
86 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
242 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 ...
15
votes
2answers
1k 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
273 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
286 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
125 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
715 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
198 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
922 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
398 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 ...
42
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
271 views
5
votes
1answer
197 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 ...
2
votes
1answer
465 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 ...
8
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
104 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
117 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
282 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
157 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
225 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
280 views

Strange Behavior of NDSolve

I am trying to evaluate the following ODE numerically: ...