Home > Uncategorized > SIAM 100-digit challenge no 1 – Matlab and Pari GP

## SIAM 100-digit challenge no 1 – Matlab and Pari GP

Continuing the SIAM 100-digit challenge presentation I show below how to solve the first problem of the series. A great bibliography for the series is the book entitled The SIAM 100-digit Challenge. A study in high-accuracy numerical computing by Folkmar Bornemann, Dirk Laurie, Stan Wagon, Jorg Waldvogel. The first problem in the series deals with the numerical integration of a highly oscillating function. As stated, the purpose is to obtain at least ten significant digits in the numerical computation.

Problem 1. Compute the limit

$\displaystyle \lim_{\varepsilon \rightarrow 0} \int_\varepsilon^1 x^{-1}\cos(x^{-1}\log(x))dx.$

The first step is to plot the function which is being integrated in order to have an idea of what we are dealing with.

Seeing these oscillations near ${0}$ is not too reassuring… There are numerical techniques which can deal with these highly oscillatory integrals. One is to split the interval into many smaller intervals accumulating at ${0}$ such that on each interval the function is simple enough such that a simple quadrature rule can be used. I will not be doing this.

Instead, let’s notice that the function does not have any singularities, except in zero, if we allow ${x}$ to take also complex values. Thus, Cauchy’s theorem regarding complex intervals says that the value of the integral does not change when we take different paths from the starting point to the end point. If ${z :[0,1] \rightarrow [0,1]}$ is defined such that ${z(0)=0}$ and ${z(1)=1}$ then the integral is equal to

$\displaystyle \int_0^1 \text{Re}(z(t)^{i/z(t)-1}z'(t))dt.$

In the experiment below I took ${z(t)=t+i\sin(\pi t)}$. First, let’s notice that the graph of this new function is much more nicer and we expect that standard integration techniques would give satisfying results.

Here’s a Matlab code that can find the first ${15}$ digits correctly. On the site of Nick Trefethen you can find the answers up to ${40}$ digits and you can check that this result has the correct first ${15}$ digits.

function problem1siam
x = 0.01:0.0001:1;
figure(1)
g = @(t) cos(log(t)./t)./t;
y = g(x);
plot(x,y)
figure(2)
z = h(x);
plot(x,z);
function res = h(t)
z = t+i*sin(pi*t);
res = real(z.^(i./z-1).*(1+i*cos(pi*t)*pi));


The Matlab result is

 0.323367431677779


The question is now, can we do more? Unfortunately Matlab cannot do multiprecision computations by default. All Matlab result are given to machine precision, that is 16 significant digits. Additional non-free toolboxes need to be installed. A nice free software which can do great multiprecision computations is Pari GP. It turns out that it has a numerical integration routine that we can put to the test below. We set the precision to ${100}$ digits and we find a result. All digits shown are correct, as we can see by comparing with the results in the site linked in the beginning. At least the first ${40}$ digits correspond to the ones on Nick Trefethen’s site.

\p 100;

g(t)    = if(t==0,return(0),\
z = t+I*sin(t*Pi); return(real(z^(I/z-1)*(1+I*cos(t*Pi)*Pi))));

Result = intnum(x=0.0000000000000001,1,g(x));


The 100 digit result is the following:

0.3233674316777787613993700879521704466510466257254696616810364434317903372106728944319303704641024514
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 14, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://mathproblems123.wordpress.com/2015/10/14/siam-100-digit-challenge-no-1-matlab-and-pari-gp/", "fetch_time": 1521657679000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2018-13/segments/1521257647681.81/warc/CC-MAIN-20180321180325-20180321200325-00258.warc.gz", "warc_record_offset": 652441527, "warc_record_length": 23465, "token_count": 887, "char_count": 3381, "score": 4.03125, "int_score": 4, "crawl": "CC-MAIN-2018-13", "snapshot_type": "latest", "language": "en", "language_score": 0.8730742335319519, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00062-of-00064.parquet"}