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

learn more… | top users | synonyms (1)

8
votes
1answer
99 views

FindMaximum failing on a trivial problem

I am trying to solve a trivial optimization problem with FindMaximum but for some reason it is not going. I reduced the problem down to the following non-working ...
0
votes
2answers
86 views
3
votes
2answers
608 views

Unexpected result of summation

I wrote a small module that gives me an incorrect output-set. It should be a single number! I don't understand what went wrong. This is the form of summation used: $$\frac{1}{2} (b-a) \sum_{i=1}^n ...
17
votes
1answer
706 views

Dual complex integral over implicit path using contour plot

Context I am interested in doing double contour integral over paths which are defined implicitly. For the sake of debugging, let's assume its $$\oint_{\cal C}\oint_{\cal C} \frac{1}{u\, x} d u d x$$ ...
0
votes
1answer
37 views

Solving recursions

This question is tied to my previous question. I have a few recursion formulas, and I keep getting Recursion depth of 1024 exceeded. error. I need to get the ...
4
votes
1answer
100 views

Why doesn't NSolve work for this equality? Wildly incorrect solutions are given in certain cases

I am trying to write a function that solves for p in the following equation: PDF[BinomialDistribution[n, p], x] == op The ...
9
votes
1answer
148 views

Eisenstein Series in Mathematica?

Mathematica doesn't seem to have built-in tools to deal with the Eisenstein series: $$\begin{align*} E_{2}(\tau)&= 1-24 \sum_{n=1}^{\infty} \frac{n e^{2 \pi i n \tau}}{1-e^{2 \pi i n \tau}}\\ ...
3
votes
1answer
37 views
11
votes
1answer
1k views

What are the algorithm details of FindRoot?

The Help page of FindRoot says: "by default, FindRoot uses Newton's method (Newton-Raphson) to solve a nonlinear system". But I ...
8
votes
1answer
183 views

What are the hidden specifications for FindRoot

The Help page of FindRoot says: "by default, FindRoot uses Newton's method (Newton-Raphson) to solve a nonlinear system" (or a nonlinear equation I ...
3
votes
2answers
64 views

How to use Evaluation Monitor in conjunction with NonlineaModelFit?

I am trying to find out how many function, gradient and hessian evaluations are made when i run NonlinearModelFit for example in this case ...
4
votes
4answers
242 views

How to stop a summation when a variable is small enough?

I meet with a problem. I hope to get an infinite summation of $f1(x)/f2(x)$ which converges to zero. So my code is Sum[f1[x]/f2[x],{x,Infinity}] or ...
22
votes
8answers
5k views

About multi-root search in Mathematica for transcendental equations

I have some questions for multiroot search for transcendental equations. Is there any clever solution to find all the roots for a transcendental equation in a specific range? Perhaps ...
1
vote
2answers
62 views

Condition on Inside of Region

How do I handle boundary conditions present in the region. Mathematica complains about the condition v [1 , t ] == u [1,t]. The condition should be given to this ...
-1
votes
3answers
248 views

Defining an alternative derivative function?

I want to calculate the derivative at a point, but I do not want to use the built-in derivative function D. I began with this definition of the derivative , ...
0
votes
2answers
69 views

Varying results from the Round function

My problem is simple. Consider the following. ...
8
votes
1answer
179 views

SymplecticPartitionedRungeKutta shows strange error

Bug introduced in 9.0 or earlier and persisting through 10.2 or later I tried to solve Hamiltonian system ($Q$ is a vector of all generalized coordinates, $P$ - of generalized momentum) $$ ...
0
votes
2answers
125 views

NDSolve issue with initial and boundary conditions

While solving the heat equation in one spatial variable $u_t = u_{xx} $ (x goes from 0 to L) with the initial temperature distribution $T_0 \frac{x(L-x)}{L^2}$ , and with neumann boundary conditions ...
3
votes
1answer
75 views

High precision calculation of infinite product involving prime numbers

I'm recently studying some topics in analytic number theory and I have encountered results involving the infinite product $$C=\prod_{p}\left(1-\frac{1}{p(p+1)}\right)$$ where $p$ denotes calculating ...
11
votes
2answers
225 views

Does Mathematica have an equivalent of C's nextafter?

In C (and many other programming languages), there is a function double nextafter(double x, double y) which takes two (IEEE 754) floating-point numbers and ...
7
votes
2answers
108 views

Erfc Not Returning Results Specified in Documentation

In the documentation for Erfc (under "Possible Issues"), the following command returns a number that is extremely close to 2: However, when I run this same command in a fresh kernel, I get: ...
0
votes
0answers
54 views

NDSolve fixed step problem

Working example here: Drive folder (have both files in the same directory! Notice: the line <<variables' in the file seems to throw an error for me, but ...
0
votes
0answers
32 views

Timing of associated Legendre polynomials

I encountered a strange issue with the associated Legendre polynomials implemented with LegendreP[l,m,z]. Quite simply, the time used for the numerical computation of those quantities depends on ...
1
vote
3answers
522 views

Setting the Accuracy of calculations

I need to optimize an expression that involves a number of trigonometric functions and Exp[]. How do I make sure that all my calculations have an accuracy of ...
8
votes
1answer
414 views

Optimizing Monte Carlo simulation of a Pred-Prey model

My assignment and code As part of an assignment for one of my classes, I'm trying to run a "massive" Monte Carlo simulation in Parallel on the follow model: ...
5
votes
1answer
93 views

Why doesn't Rationalize work for 0. in Interval?

Same motivation as this q. Why doesn't Rationalize work for 0.? Interval[{0., 1.}] // Map[Rationalize, #, {2}] & ...
21
votes
2answers
254 views

BitShiftRight produces incorrect results in Version 10

Bug introduced in 10.0.0 and fixed in 10.0.2 With Mathematica 10 for Mac, BitShiftRight works properly on lists of up to 100000 numbers, but appears to give ...
4
votes
2answers
69 views

Is there a way for accuracy backtick notation to accept variable inputs?

Backtick notation uses 1.0``20 to give 1 with 20 places of accuracy after the decimal point. But what I want is ...
1
vote
0answers
26 views

Function assigning loop misses a beat [duplicate]

Ive come across this in managing a table, but is seems to be reproducible in simpler forms. I simply want to iterate a defined function for various values and then work with those at a later time. ...
4
votes
1answer
181 views

Mod[1.2, 0.2] is not equal to zero

Why doesn't the following expression evaluate to zero? In[1]:=Mod[1.2, 0.2] Out[1]=0.2 Edit: This is what I wanted to do: ...
1
vote
0answers
105 views

MatrixExp of a complex matrix of size about 10000 by 10000 [closed]

I want to apply MatrixExp of a numerical, complex matrix of size about 10000 by 10000, and I also need high precision as I need to multiply several such matrices. ...
0
votes
1answer
52 views

Problem with solving coupled differential equations

The following code seem to produce an output that appears to be independent of the parameter "fg". It is possible that the way the code is written might be causing it, but how can one fix this ...
28
votes
1answer
962 views

Fast Spherical Harmonics radiative transfer

This is a rather specific question and I apologize for spamming you with some lengthy code. But it could be interesting for some reader and maybe you can help out, so please bear with me. I am using ...
2
votes
0answers
61 views

Funny behavior when computing dot product of coefficients with high-order polynomials

I have a similar problem to Funny behaviour when plotting a polynomial of high degree and large coefficients. However, the thing being evaluated is not just a polynomial but a dot product of some ...
12
votes
1answer
2k 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 ...
7
votes
0answers
212 views

Mathematica 7: “LessEqual::nord:” error when using NMinimize on a real function

Bug introduced in 7.0 or earlier and fixed in 9.0 I encounter a problem (Mathematica 7) similar to Strategies to avoid LessEqual::nord in NMinimize? but the advised strategies don't work for me. ...
2
votes
0answers
65 views

What am I missing in this highly oscillatory integral?

I want to numerically integrate this equation (in python without calling Mathematica): $\int_0^\infty {\rm d}k f(k) J_v(r k) J_n(s k)$ where $f(k)$ is a non-smooth function, $J_v$ are the Bessel ...
14
votes
1answer
445 views

How to determine BLAS/LAPACK implementation used internally for numerical matrix operations?

Is there a command which reveals which implementation of BLAS and LAPACK are used in Mathematica's matrix operations such as Eigensystem? I asked a related question ...
3
votes
2answers
208 views

Storing Variables in “Loops” and Point Plotting

Given the function $y=\sin x$ defined over the region $-\pi \leq x \leq \pi$, I need to implement a "do loop" such that I sweep over 100 or so points $-1 \leq y \leq 1$ and find precisely the two $x$ ...
2
votes
1answer
126 views

NMaximize and Accuracy

I have a problem with NMaximize which is best depicted by the following figure. The result indicates, that the solution mathematica finds seems to be smooth except a few outliers. How can I get rid of ...
6
votes
1answer
423 views

Is there no documentation for Method in Eigensystem?

There does not appear to be any documentation on how to use Method in Eigensystem, or at least not in Version 9.0.1 of ...
4
votes
1answer
133 views

Unexpected results from trying to solve Laplace's equation

I am trying to find the solution to Laplace's equation: $\dfrac{\partial^2 u}{\partial x^2}+\dfrac{\partial^2 u}{\partial y^2}=0$ over the following region of space: the vertices of the triangle ...
16
votes
2answers
974 views

How to compute the inverse CDF of HyperbolicDistribution properly?

Fixed in version 9. I want to compute the CDF and inverse CDF of the hyperbolic distribution: ...
7
votes
1answer
557 views

How to solve fluid flow problem based on Navier-Stokes equations?

Does anyone know or can provide any examples how fluid flow problem can be formulated and solved in Wolfram Language? Simplest cases of 1D or 2D flows based on Navier-Stokes equations or even their ...
0
votes
1answer
36 views

Error message when exporting plot as XLS file

I imported data from excel which has 300 data (which are change in CDS spread). I want to compute corresponding CDF for the data using kernel density estimation. I get the CDF plot but cannt get the ...
3
votes
2answers
147 views

WorkingPrecision causes issue in the NIntegrate

I really can't figure out why my code sometimes is not working. My integrals involve two variables (k and kz). The integration ...
9
votes
1answer
167 views

Comparing exact expressions for equality — is it really OK if I get wrong answer?

Bug introduced in 7.0 or earlier and fixed in 10.2.0 I found an unexpected behavior (that I think of as a bug) in evaluation of the equality operator applied to mathematical functions with exact ...