Archive

Posts Tagged ‘numerical analysis’

Is the Earth flat?

November 28, 2023 3 comments

Consider the following experiment: the pairwise distances between four cities on Earth are given. Can you answer the following questions:

1) Can these distances be realized in a flat Earth?

2) Assuming the Earth is spherical and distances are measured along geodesics, can you determine the radius?

The test case was inspired from the following note. The initial test case involves the cities: Seattle, Boston, Los Angeles and Miami. A second test case is provided below.

You can use the Python code to create new test cases of your own. 

Read more…

Explicit Euler Method – practical aspects

February 6, 2022 Leave a comment

In a previous post I presented the classical Euler methods and how they apply to the simple pendulum equation. Let me now be a little more explicit regarding the coding part. I will present a Python code and give you some main ideas, important from my point of view, regarding the implementation. Here is a summary of these ideas

  • Use numpy in Python. When performing numerical simulations related to ODEs it is recommended to work in floating point precision. This will give you accurate enough results (at least for usual academical examples) and will produce a more efficient code.
  • Structure the code using functions. The code for the Explicit Euler method should be easily adaptable to other problems, by changing the function defining the ODE (like shown in this post)
  • Any numerically implemented method for solving ODEs should be tested on a simple example where the analytical solution is known. In particular, the convergence order of the method can be identified and should coincide with the theoretical prediction. This can easily help debug implementation errors for more complex methods.
  • When the ODE comes from an isolated system where there is an invariant (like the energy for the pendulum), the numerical preservation of this invariant should be tested. Errors might be seen, but they should be quantifiable in terms of the step size and the order of the method. Aberrant results here could indicate the presence of a bug.
Read more…

Simple Pendulum – Euler methods

January 31, 2022 1 comment

Given {f: \Bbb{R}\times \Bbb{R}^d \rightarrow \Bbb{R}^d}, Lipschitz in the second variable, consider the ODE

\displaystyle \dot y = f(t,y), y(0) = y_0 \in \Bbb{R}^d. \ \ \ \ \ (1)

In most cases where equation (1) models some real world phenomena, the solutions are not explicit. Therefore, numerical methods are developed in order to solve such problems.

Read more…

The simple pedulum

January 30, 2022 1 comment

PendulumIn physics the simple pendulum is a punctual mass fixed at the extremity of a wire without mass and in-extensible (or rigid), which oscillates under the effect of gravity. It is straightforward to see that if the point of attachment of the wire is fixed, then the resulting dynamical system can be uniquely determined knowing the inclination {\theta} of the wire with the vertical and the parameters of the system (mass, length of wire, gravitational acceleration). The easiest way of deriving the equation of movement for the pendulum (supposing there is no friction) is to write the total energy of the system. The angular speed of the pendulum being {\dot \theta} we find that the speed of the point mass is {v = l\dot \theta}. This shows that the kinetic energy of the mass is {E_c=\frac{1}{2} m l^2\dot \theta^2}. The potential energy due to the gravitational force is {E_p= mgl(1-\cos \theta)}, assuming that {\theta=0} corresponds to zero height. Therefore, the total energy is given by

\displaystyle E = E_c+E_p = \frac{1}{2} m l^2 \dot \theta^2 + mgl(1-\cos \theta).

Supposing the system is isolated and no energy is lost due to friction we have that the derivative of the energy {E} with respect to time is zero:

\displaystyle \dot E_m =ml^2 \dot \theta \ddot \theta +mgl \sin \theta \dot \theta = 0.

Read more…

Checking the gradient and Hessian implementation using finite differences

April 14, 2021 Leave a comment

Solving a numerical optimization problem depends not only on the optimization algorithm you use, but also on the fact that you implemented correctly the gradient and, eventually, the Hessian matrix associated to the function you want to optimize. The correct implementation of the partial derivatives is not always a trivial calculus question, where you have an analytic formula for your function and you just need to take care when performing the computations. However, even the best students can make a typing error, put a wrong sign somewhere, miss a factor, etc, and in that case the optimization algorithm simply doesn’t work as expected.

Things get even more complicated when the computation of the gradient (and Hessian) goes through some PDE model, multiplying the places in your code where an error might hide. For example in some parametric shape optimization problem, one has a parametric description of the shape and the gradient of the function to be optimized is obtained by putting in the associated shape derivative formula a perturbation field associated to the variation in the corresponding parameter.

Read more…

Gradient algorithm with optimal step: Quadratic Case: theory

April 6, 2021 Leave a comment

In a previous post I looked at the theory behind the convergence of the gradient descent algorithm with fixed step for a quadratic function. In this post I will treat a similar topic, namely the gradient descent algorithm with optimal step for the case of a quadratic function. Let us consider again {J:\Bbb{R}^n\rightarrow \Bbb{R}} defined by

\displaystyle J(x) = \frac{1}{2}\langle Ax,x\rangle -\langle b,x \rangle,

the classical quadratic function, where {A} is symmetric positive definite and {b} is an arbitrary vector. The gradient descent algorithm with optimal step has the form

\displaystyle x_{k+1} = x_k - \mu_k \nabla J(x_k),

where the descent step {\mu_k} is chosen such that

\displaystyle \mu \mapsto J(x_k - \mu \nabla J(x_k))

is minimal.

Read more…

Gradient algorithm: Quadratic Case: theory

March 31, 2021 1 comment

Everyone who did a little bit of numerical optimization knows the principle gradient descent algorithm. This is the simplest gradient based algorithm: given the current iterate, advance in the opposite direction of the gradient with a given step

\displaystyle x_{k+1} = x_k - \mu \nabla J(x_j).

It is straightforward to see that if {\rho} is small enough, {\nabla J(x_k) \neq 0} and {J} is at least {C^1} then

\displaystyle J(x_{k+1}) = J(x_k)-\mu |\nabla J(x_k)|^2 +o(\rho).

This means that there exists a {\rho_k} small enough for which {J(x_{k+1})<J(x_k)}.

Read more…

Recurrences converging to the wrong limit in finite precision

March 8, 2021 Leave a comment

Consider the following recurrence:

\displaystyle x_0 = 4, \ x_1 = 4.25, \ x_{n+1}=108-(815-1500/x_{n-1})/x_n, \forall n \geq 1.

a) Study this recurrence theoretically: prove that the sequence converges and find its limit.

b) Implement the recurrence using the programming language of your choice and see what is the limit obtained by numerical investigation. Interpret the results!

Read more…

Gradient Descent converging to a Saddle Point

April 19, 2020 Leave a comment

Gradient descent (GD) algorithms search numerically for minimizers of functions f:\Bbb{R}^n \to \Bbb{R}. Once an initialization x_0 is chosen the algorithm is defined by

x_{n+1}=x_n-t_n\nabla f(x_n)

where t_n is a descent step, often found using a particular line-search procedure. It is widely known that GD algorithms converge to critical points under very mild hypotheses on the function f and on the line-search procedure. Moreover, GD algorithms almost always converge to local minimizers (convergence to the global minimizer is hard to guarantee, except in the convex case).

However, the “almost always” part from the above sentence is in itself interesting. It turns out that the choice of the initialization may lead the algorithm to get stuck in a Saddle Point, i.e. a critical point where the Hessian matrix has both positive and negative eigenvalues. The way to imagine such examples is to note that at such a Saddle Point there are directions for which f is minimized and directions for which f is maximized. If the gradient only contains information in the direction where f is minimized, the algorithm will stop there. However, the set of initializations for which GD will get stuck in a Saddle Point is very small and considering slightly perturbed initializations might solve the problem.

To better illustrate this phenomenon, let’s look at a two dimensional example:

f(x,y) = (x^2-1)^2(1+y^2)+0.2y^2.

It can be seen immediately that this function has critical points at (0,0),(\pm 1,0) and that (0,0) is a saddle point, while the other two are local minima. A graph of this function around the origin is shown below

Saddle_point_3D

Note that looking only along the line x=0 the saddle point is a minimizer. Therefore, choosing an initialization on this line will make the GD algorithm be stuck in the Saddle Point (0,0). Below you can see an example for the initialization x_0 = (0,1.5), and the trajectory of the GD algorithm is illustrated. Considering only a slight perturbation x_0 = (10^{-6},0.5) allows the GD algorithm to escape the saddle point and to converge to a local minimizer.

 

One simple way to prevent GD algorithms being stuck in a saddle point is to consider randomized initializations so that you avoid any bias you might have regarding the objective function.

On Heron’s algorithm – approximating the square root

November 22, 2019 Leave a comment

Heron’s algorithm computes an approximation of the square root of a positive real number using the iteration

\displaystyle x_0 >0,\ x_{n+1} =\frac{1}{2}\left( x_n+\frac{y}{x_n}\right). \ \ \ \ \ (1)

  1. Show that the recurrence defined above is Newton’s algorithm applied for finding a zero of the function {f(x) = x^2-y}. Show that the sequence {(x_n)} converges to {\sqrt{y}} when {x_0} is close enough to {\sqrt{y}}. What is the order of convergence of the sequence?In the following we consider the following error measure:

    \displaystyle E_y(x) = \frac{x-\sqrt{y}}{x+\sqrt{y}}.

    This choice simplifies the computations and is an estimation of half the relative error when {x \rightarrow \sqrt{y}}.

  2. Show that the sequence {(x_n)} verifies

    \displaystyle E_y(x_{n+1}) = E_y(x_n)^2.

    Deduce an explicit formula for {E_y(x_n)} in terms of {E_y(x_0)}. Show that the sequence {x_n} converges to {\sqrt{y}} for every choice of the initial condition {x_0>0}.

  3. Show that for every {y>0} there exists an integer {k \in \Bbb{Z}} such that {4^ky \in [1/2,2]}. Write a modified Heron algorithm which reduces the computation of the square root of {y>0} to the computation of the square root of a real number {\tilde y \in [1/2,2]}.The choice of the initialization {x_0} determines {E_y(x_0)} and has an influence on the speed of convergence. In the following we restrict ourselves to the case {y \in [1/2,2]} and we look at the choice of the initial condition. We will suppose that the initial condition depends on {x_0} and we will consider the following cases: {x_0 = a}, a constant function and {x_0 = a+by}, a polynomial of degree {1} in {y}. In every case we will try to minimize {\|g\|_{L^\infty([1/2,2])}} for {g(y) = E_y(x_0)}.
  4. Show that if {x_0=a} then {M_a = \max_{y \in [1/2,2]} |E_y(a)|} is minimal for {a=1}. Find the explicit value of {M_a}. (Hint: You could represent graphically the function {y \mapsto |E_y(a)|}.)
  5. Suppose that {x_0 = a+by} is a polynomial of degree {1} in {y}. We want to find the coefficients {a} and {b} which minimize {M_{a,b}=\|g\|_{L^\infty([1/2,2])}} with {g(y)=E_y(a+by)}.
    (a) Prove that the maximum of {y \mapsto |g(y)|} is found for {y\in \{a/b,1/2,2\}}.
    (b) Show that in order to minimize {M_{a,b}} it is necessary that {a=b} and that {g(2)=g(1/2)=-g(a/b)}.
    (c) Conclude that the {a} and {b} which minimize {M_{a,b}} are {a=b=\sqrt{\sqrt{2}/6}}. Find an exact expression for {M_{a,b}}.
  6. For {y=2} compare the number of iterations necessary to arrive at a demanded precision ({E_y(x_n)<\text{tol})} for the two initializations studied: {x_0=1} and {x_0 = ay+b} with {a=b=\sqrt{\sqrt{2}/6}}. Comment on the interest of using the initialization of degree {1} compared to the constant initialization
  7. Evaluate the number of operations used for the two cases and conclude which of the two approaches is more advantageous.
  8. Try to find the initialization of second degree which is optimal and perform a similar investigation to see if from the point of view of the number of operations this choice is well adapted or not.

Condition number of a matrix

October 26, 2019 Leave a comment

Let {A} be a {n \times n} real matrix which is invertible. For a vector {b \in \Bbb{R}^n} we solve the system

\displaystyle Ax=b. \ \ \ \ \ (1)

The condition number of a matrix gives an idea on the behavior of the solutions {x} with respect to perturbations of the vector {b}. Given a perturbation {\delta b}, consider {x+\delta x} the solution of the associated system:

\displaystyle A(x+\delta x) = b+\delta b

1. If {b\neq 0}, show that

\displaystyle \frac{\left\Vert \delta x \right\Vert}{\left\Vert x \right\Vert} \leq \kappa(A) \frac{\left\Vert \delta b \right\Vert}{\left\Vert b \right\Vert},

where

\displaystyle \kappa(A) = \|A^{-1}\|\|A\|.

This quantity is the condition number of {A}. Note that the condition number depends on the chosen norm.

2. Show that if {A} is invertible and symmetric and we consider the Euclidean norm, then

\displaystyle \kappa_2(A) = \frac{\max_{\lambda\in Sp(A)} \vert\lambda\vert}{\min_{\lambda\in Sp(A)} \vert\lambda\vert},

where {\kappa_2} is the condition number for the norm {\left\Vert \cdot \right\Vert_2}Hint: Use the fact that {A} is diagonalizable in an orthonormal basis.

3. Consider the following example (attributed to H. Rutishauser) :

\displaystyle A=\begin{pmatrix} 10 & 1 & 4 & 0 \\ 1 & 10& 5 & -1\\ 4 & 5 & 10 & 7 \\ 0 & -1 & 7 & 9 \end{pmatrix} \text{ with } b_1 = \begin{pmatrix} 15\\15\\26\\15 \end{pmatrix} \text{ and } b_2 = \begin{pmatrix} 16\\16\\25\\16 \end{pmatrix}

Compute the determinant of {A} and the inverse of {A}. You can use numerical tools like “numpy.linalg.inv” and “numpy.linalg.det”. Solve the systems {Ax_1=b_1} and {Ax_2 = b_2} using either the inverse found previously or “numpy.linalg.solve”. Explain the behavior obtained and give a lower bound for the condition number of the matrix {A}. Compute the condition number of {A} using the following methods

  • compute the eigenvalues of {A} with “numpy.linalg.eig” and use the previous point
  • use “numpy.linalg.cond”

Conclude that the lower bound found previously was not so far from the condition number. Try to find other examples of {b_1} and {b_2} which can get you arbitrarily close to the condition number.

Integrating an oscillatory function

September 16, 2019 Leave a comment

Consider the function {f: [0,1] \rightarrow [-1,1], \ f(x) = \sin(1/x)} extended in zero with {f(0)=0}. The objective of this exercise is to prove that the integral {I =\displaystyle \int_0^1 f(x)dx} exists and to give a numerical approximation of {I}. A graphical representation of f is shown below:

SinOsc

1. Use your favorite numerical tool (for example \texttt{scipy.integrate}) in order to evaluate directly the integral {f} on {[0,1]}. Explain the eventual error messages and comment on the eventual error messages obtained.

2. Consider the decreasing sequence {a_k} of zeros of {f}. Obtain the integral of {f} like a series of integrals of {f} on the intervals {[a_{k+1},a_k]}. Use again your favorite numerical tool (e.g. \texttt{scipy.integrate}) for each of the previous intervals for {k \leq N}. Find a good stopping criterion which says you have found a good approximation of {I}. How can you accelerate the convergence. What other choice do you have for the choice of the sequence {(a_k)} ?

3. Show that

\displaystyle \int_0^1 f(x)dx = \cos 1 - \int_0^1 2x\cos(1/x)dx.

Evaluate this expression with the aid of a numerical software and compare the precision to the result obtained at the previous points. Explain the eventual gain of precision compared to point 1. 4. The function integral cosine is defined by

\displaystyle \text{Ci}(x) = -\int_x^\infty \frac{\cos t}{t}dt.

Prove that {I = \sin 1 - \text{Ci}(1)}. Use a numerical tool which allows you to obtain {I} to machine precision.

Remark: The precise evaluation of {\text{Ci}(x)} can be found using the following series representation of {\text{Ci}} on {\Bbb{R}_+^*}:

\displaystyle \text{Ci}(x) = \gamma + \ln (x) +\sum_{n=1}^\infty (-1)^n \frac{x^{2n}}{(2n)!(2n)}

where {\gamma} is the Euler-Mascheroni constant. 5. Consider the function {h: \Bbb C \rightarrow \Bbb C} defined by {h(z) = -\exp(-i/z)}.

Show that the integral {I} corresponds to the imaginary part of {h} on the path {\gamma_0 : [0,1]\rightarrow \Bbb{C}}, {\gamma_0(t) = t}. Consider the alternative path {\gamma_1 : [0,1] \rightarrow \Bbb{C}}, {\gamma_1(t) = t+it(1-t)}.

Prove that {h(z)} is bounded in the region {\arg z \in [0,\pi]}. Deduce using Cauchy’s theorem that

\displaystyle \int_{\gamma_0} h(z)dz = \int_{\gamma_1} h(z)dz.

Prove that on the new path the function {h} does not oscillate. Moreover, as {t \rightarrow 0} on {\gamma_1} the {h(\gamma(t))} converges exponentially to zero.

Use a numerical tool (e.g. \texttt{scipy.integrate}) to compute the integral of {h} on the path {\gamma_1}. Recall that:

\displaystyle \int_{\gamma_1} h(z)dz = \int_0^1 h(\gamma_1(t))\gamma_1'(t)dt.

Compare the result to the ones obtained before and conclude why the numerical software manages to approximate correctly the integral of {h} on the path {\gamma_1}.

What can go wrong with numerics

September 2, 2019 Leave a comment

I recently watched the video Validated Numerics by Warwick Tucker. This video is an introduction to interval arithmetic, which is a rigorous way of doing numerics with nice applications. In the first part of the video, however, he starts by showing some examples where the numerics can go wrong.

First, in order to understand why computations done by a machine can be wrong, you need to know how the computer looks at numbers. Since the computer has a finite amount of memory, it will never store exact representations. Irrational numbers with infinitely many digits repeating without any pattern whatsoever are clearly not representable. Even rational numbers, which are the ratios of two integers may be costly to represent if the integers involved are quite large. When working with simulations one often manipulates not one variable but vectors and matrices with millions of variables. Therefore it is necessary to bound the memory allocated to each one of these variables. This is why the floating point arithmetic was introduced.

A floating point number (in some basis, binary for the computer, decimal for the usual representation) is composed of a real number m called the mantissa and an exponent e. The catch is that the mantissa will store only finitely many digits and usually it is normalized, i.e. there are no zeros after the decimal point. For example:

  • 1.01011 is a valid mantissa with 5 binary digits (the leading 1 is not counted)
  • 0.00101 is not a normalized mantissa since there are zeros after the decimal point
  • 1011.01 is not a normalized mantissa since there are more then one digits before the decimal point

The mantissa alone, in binary representation, will only represent numbers between 1 and 2. However, one can reach more numbers using a multiplication with a power of two, contained in the exponent. Therefore, the computer knows a number by its finite precision mantissa and its exponent. The sign of the number can also be included in one bit. I will not try to make an exhaustive lecture on floating point representations: you should check other references for more information.

Using this floating point representation, the problem of memory is solved, but the thing is that operations using floating point numbers are not exact. In order to make an addition the computer needs to shift the decimal point so that the two numbers have the decimal point at the same place. The problem is that every time this is done, information is lost at the other end of the mantissa.

The following example is shown in the book “Validated Numerics” and is due to Rumpf (the creator of Intlab, an interval arithmetic for Matlab). Consider the function

f(x,y) = 333.75y^6+x^2(11x^2y^2-y^6-121y^4-2)+5.5y^8+x/(2y)

Then, depending on the size of the floating point representation or on the convention made when performing the rounding the evaluation of f(77617,33096) gives different results. The idea is that the two terms 5.5y^8 and 333.75y^6+x^2(11x^2y^2-y^6-121y^4-2) evaluated at the corresponding point give rougly the same 37 digit number. Their exact sum is -2 which coupled with the last term should give -0.827....

However, when adding those two huge numbers multiple things may happen:

  • the computer sees that they are roughly the same so it supposes that their difference is zero
  • the computer makes some random operation after the 21th digit in 64 bits (where we roughly have 16 significant digits of precision)

In the end, the result shown is not correct, unless we work with multiple precision arithmetics.

This should not discourage us in using numerical computations, which are useful in many practical application. On the other hand we should be aware that when doing computations in floating point representation results are only approximate. Particular care should be made when subtracting two numbers which are close but which are not exactly represented using the floating point system.

 

FreeFem++ Tutorial – Part 1

February 24, 2016 2 comments

First of all, FreeFem is a numerical computing software which allows a fast and automatized treatment of a variety of problems related to partial differential equations. Its name, FreeFem, speaks for itself: it is free and it uses the finite element method. Here are a few reasons for which you may choose to use FreeFem for a certain task:

  1. It allows the user to easily define 2D (and 3D) geometries and it does all the work regarding the construction of meshes on these domains.
  2. The problems you want to solve can be easily written in the program once we know their weak forms.
  3. Once we have variables defined on meshes or solutions to some PDE, we can easily compute all sorts of quantities like integral energies, etc.

Before showing a first example, you need to install FreeFem. If you are not familiar with command line work or you just want to get to work, like me, you can install the visual version of FreeFem which is available here. Of course, you can find example programs in the FreeFem manual or by making a brief search on the internet.

I’ll present some basic stuff, which will allow us in the end to solve the Laplace equation in a circular domain. Once we have the structure of the program, it is possible to change the shape of the domain in no time.

Read more…

Even small errors can be fatal

October 14, 2015 Leave a comment

Machines and computers represent numbers as sequences of zeros and ones called bits. The reason for doing this is the simplicity of constructing circuits dealing with two states. This fact coupled with limited memory capacities means that from the start we cannot represent all numbers in machine code. It is true that we can get as close as we want to any number with great memory cost when precision is important, but in fact we always use a fixed precision. In applications this precision is fixed to a number of bits (16, 32, 64) which correspond to significant digits in computations. Doing math operations to numbers represented on bits may lead to loss of information. Consider the following addition using {15} significant digits:

\displaystyle 5.00000000000002+6.00000000000003 = 11.0000000000000,

notice that using only the first {15} significant digits we have made an error of {5\times 10^{-14}}. This may seem small, but if we do not pay attention and we let errors of this kind accumulate we may have a final error which is unacceptable. This is what happened in the case of the Patriot missile case which I’ll discuss briefly below.

Read more…

Solving Poisson’s equation on a general shape using finite differences

October 14, 2014 4 comments

One of the questions I received in the comments to my old post on solving Laplace equation (in fact this is Poisson’s equation) using finite differences was how to apply this procedure on arbitrary domains. It is not possible to use this method directly on general domains. The main problem is the fact that, unlike in the case of a square of rectangular domain, when we have a general shape, the boudary can have any orientation, not only the orientation of the coordinate axes. One way to avoid approach this problem would be using the Finite Element Method. Briefly, you discretize the boundary, you consider a triangulation of the domain with respect to this discretization, then you consider functions which are polynomial and have support in a few number of triangles. Thus the problem is reduced to a finite dimensional one, which can be written as a matrix problem. The implementation is not straightforward, since you need to conceive algorithms for doing the discretization and triangulation of your domain.

One other approach is to consider a rectangle {D} which contains the shape {\Omega} and add a penalization on the exterior of your domain {\Omega}. The problem to solve becomes something like:

\displaystyle (-\Delta +\mu I) u = 1 \text{ on }D

where {\mu} is defined by

\displaystyle \mu(x) = \begin{cases} 0 & x \in \Omega \\ + \infty & x \notin \Omega\end{cases}. \ \ \ \ \ (1)

Note that doing this we do not need to impose the boundary condition {u=0} on {\partial \Omega}. This is already imposed by {\mu}, and the fact that {u} is forced to be zero outside {\Omega}.

Read more…

Simple optimization problem regarding distances

March 27, 2014 Leave a comment

Given {n} points {A_1,...,A_n} in the plane we can study the problem

\displaystyle \min_M MA_1+...+MA_n.

For {n=3} the solution is known and for a triangle which has an angle less than {120^\circ} is the Toricelli (or Fermat) point, which lies at the intersection of the circumcircles of the equilateral triangles built outside the triangle having the sides of the triangle as support.

For {n=4}, if we have a convex quadrilateral, then a simple triangle inequality argument proves that the optimal position for {M} is the intersection of the diagonals.

In general, we cannot precisely say what is the position of the solution. Providing a numerical algorithm which computes the optimal position of {M} is not a hard task, and I will do that in the end of this post.

 

Read more…

Numerical method – minimizing eigenvalues on polygons

December 23, 2013 1 comment

I will present here an algorithm to find numerically the polygon {P_n} with {n} sides which minimizes the {k}-th eigenvalue of the Dirichlet Laplacian with a volume constraint.

The first question is: how do we calculate the eigenvalues of a polygon? I adapted a variant of the method of fundamental solutions (see the general 2D case here) for the polygonal case. The method of fundamental solutions consists in finding a function which already satisfies the equation {-\Delta u=\lambda u} on the whole plane, and see that it is zero on the boundary of the desired shape. We choose the fundamental solutions as being the radial functions {\Phi_n^\omega(x)=\frac{i}{4}H_0(\omega|x-y_n|)} where {y_1,..,y_m} are some well chosen source points and {\omega^2=\lambda}. We search our solution as a linear combination of the functions {\Phi_n}, so we will have to solve a system of the form

\displaystyle \sum \alpha_i \Phi_i^\omega(x) =0 , \text{ on }\partial \Omega

in order to find the desired eigenfunction. Since we cannot solve numerically this system for every {x \in \partial \Omega} we choose a discretization {(x_i)_{i=1..m}} on the boundary of {\Omega} and we arrive at a system of equations like:

\displaystyle \sum \alpha_i \Phi_i^\omega(x_j) = 0

and this system has a nontrivial solution if and only if the matrix {A^\omega = (\Phi_i^\omega(x_j))} is singular. The values {\omega} for which {A^\omega} is singular are exactly the square roots of the eigenvalues of our domain {\Omega}.

Read more…

Best approximation of a certain square root

November 29, 2013 Leave a comment

Let {\lambda} be a real number such that the inequality

\displaystyle 0 < \sqrt{2002}-\frac{a}{b} < \frac{\lambda}{ab}

holds for an infinity of pairs {(a,b)} of natural numbers. Prove that {\lambda\geq 5}.

Read more…

Distance from a point to an ellipsoid

October 17, 2013 5 comments

Here I will discuss the problem of finding the point which realizes the minimal distance from a given {x_0} to an ellipsoid. First I will look at the theoretical properties which will lead us to {x_0} and then I will present a numerical algorithm to find the nearest point.

This problem is interesting in itself, but has some other applications. Sometimes in optimization problems we need to impose a quadratic constraint, so after a gradient descent we always project the result on the constraint which is an ellipsoid.

Let’s begin with the problem, which can be formulated in a general way like this: we are given {y \in \Bbb{R}^n}, and a matrix {A}, positive semidefinite, which gives an ellipsoid {x^TAx=1}. Without loss of generality assume that {A} is diagonal (if not, we diagonalize it using an orthogonal matrix and work in a new coordinate system). The problem becomes

\displaystyle \min_{x^TAx=1} \|x-y\|^2.

(note that the square is not important here, but simplifies the computations later)

Read more…