math

Interactive Main and Variance

Michael Jacobsen
This article tries to explain multiple concepts from statistics using a small Javascript illustration of the correlation of two variables. The normal distribution in one dimension is described by the probability distribution $$ f(x) = \frac{1}{\sigma \sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}} $$ where \( \mu \) is the mean and \( \sigma \) is the standard deviation. While the mean is easily understood, the standard deviation measures how spread out the distribution is. A large \( \sigma \) implies that numbers further from the mean are more likely.

Creating Fractals with Web Workers

Michael Jacobsen
A Web Worker makes it possible to run Javascript code without blocking the user interface. That is, computations can be made in the background without locking the user interface. A Web Worker is created as follows // Main script var worker = new WebWorder( url ); where url must point to a Javascript file. The script is started immediately. This article describes the ‘standard’ Web Worker, not the ‘shared’ Web Worker.

Experiments with PovRay

Michael Jacobsen
All the scenes are version controlled on my GitHub page. You may do whatever with it - but I would like to hear about it - in the unlikely case that anyone do anything like that. Headers In order to improve the look of a previous version of this site, I switched to a theme which included the option to rotate between a number of images in the header. The header1.

Blur - Deblurring an Atmospheric Blurred Image

Michael Jacobsen
During my Ph.D. I made a java applet demonstrating an inverse problem. This article brings the applet back. When light passes throug e.g. air it gets blurred. That is why telescopes are built on top of mountains so that the weak light from the stars travels through less air. The extreme case is the Hubble telescope placed in orbit around the earhth without any atmosphere to distort, i.e., blur the image.

How far can you see?

Michael Jacobsen
How far can you see when you are, say, 2 meters high? Lets find out assuming that we stand on a perfect circle with perfect visibility (and that we do not have refraction). The Math In Figure 1 I have sketched the situation. The distance (c) is the radius of the sphere (could be the radius of the earth). The distance (a) is the hight of the observer above the circle.

Project Euler 35

Michael Jacobsen
To create the rotations I make a “detour” by converting the number into a string and then performing the rotations on the string. #light let primes_below v = Euler_utils.primes | Seq.takeWhile (fun p - p Set.of_seq let rotate number = let number_str = number.ToString() let len = number_str.Length - 1 seq { for i in [ 1..len ] do yield int64 (number_str.Substring(i) + number_str.Substring(0,i)) } let has_rotated set number = let numbers = rotate number Seq.

Project Euler 48

Michael Jacobsen
In order to keep the numbers in check we use the rule that $$ a \equiv v (\bmod m) \Rightarrow a b \equiv v b (\bmod m) $$ This rule is implemented in the powermod function. Note, that the powermod function is not yet “tail recursive” and is therefore vulnerable to stack overflow for (very) large b. #light let rec powermod a b m = if b = 0I then 1I else (a*(powermod a (b-1I) m)) % m let sum = let numbers = [1I .

Average Distance on a Circle

Michael Jacobsen
What is the average distance between two points on a circle? We define the distance as going through the circle as going around the circle reduces the problem to the problem of average distance on a line, see [Average Distance on a Line](Average Distance on a Line). The circle as one of the most symmetric shapes we can thing of. Thus we can select the (1,0) on the unit circle and compute the average distance to any other point.

Euler problems 18 and 67

Michael Jacobsen
Problems 18 and 67 differs in their size, where problem 67 is so large that a (naive) brute force algorithm would not end within reasonable time. A simple algorithm shows it self if we goes from the bottom up. The problem formulation displays the numbers such that one looks at the numbers from the top going down. Look at one “sub-triangle” at the bottom such as (the very left one)

Project Euler

Michael Jacobsen
F# has a lot of functionality for manipulation of lists. Here is my first attempt at the solution in F#. let numbers35 = List.filter (fun i - i % 3 = 0 or i % 5 = 0) [1 .. 999];; printfn "Euler project problem 1 : %d" (List.fold_left (+) 0 numbers35);; I could have merged the two lines into one. However, I find this a bit more clear. The filter function filters (!