Posts

Showing posts with the label matlab

Random Walks to solve Diophantine Equations

Image
Random walks (check my older post here ) and Diophantine equations are two simple mathematical beasts. After a college seminar, I tried putting them together to make something neat, and came up with this: just pick a Diophantine equation, simulate a random walk, and try to see if the random walk went over any solutions! In this report I briefly go over how I came up with this, and show the code I wrote/some results. The Matlab code is all in here (I also have some Python code about random walks in general here , check my post !). In the image above, the blue line represents a path taken by the random walk and in orange/red the nodes tell us how far we are from a solution (the smaller the node, the closer we are). Note that this notion of proximity isn't given by actually computing the distance to a known solution, but just by looking at how similar the two sides of the equation are. The image below shows the evolution of three independent random walks trying to find an example ...

A gradient descent algorithm to optimally distribute points in a sphere

Image
In this first post I want to share with you guys a piece of code I wrote to "solve" a problem where geometry meets optimization. I say "solve" because I didn't actually do anything that fantastic regarding the actual problem I address, but rather developed a small tool to help visualize the geometrical part of the problem. Even so, I do believe that for the smaller cases my tool can solve the problem. The problem is along the lines of: define an energy function whose value depends on the positions of points in a sphere, and now try to minimize/maximize it (depending on a parameter). That is it. I used my coding skills to write an algorithm that solves this when the number of points is small, and that lets me see the creation of the solution: I create a random possible distribution of points and then let them adjust themselves to their desired positions, hopefully reaching the desired minimum/maximum. In here you can find the report I wrote for this, in English....