## Friday, May 13, 2016

### UnGauss

Supposing you had some initial point source locations, perhaps at the integers, and a standard deviation of a gaussian effect, you can undo the gaussian effect like so:

Set x(i)'s equal to the point source locations, and t^2 equal to the gaussian effect standard deviation...
Now setting this sum evaluated at each x(i) equal to the final intensity at xi gives a system of n linear equations in n unknowns that can be solved...
For example this could be the final distribution after a gaussian effect with a standard deviation of 1:
It has values .2, .25, .2 at x(i) = 1,2,3
The solve command will look like:
Plugging these coefficients into the equation and setting the standard deviation to a lesser value undoes the Gaussian effect, here I've stepped it back to t=.2:
The lower t is set the sharper the peaks...

## Sunday, April 17, 2016

### Rectangle warping

Solving this type of system of linear equations you can do any dimension rectangular grid and warp the picture any way even into 3 dimensions or over time!

## Tuesday, February 23, 2016

I've collected all the best ideas on this blog and improved the presentation from these past 5 years and posted them over at a Facebook public page:

### Windmill sail boat

Just a thought experiment... I wonder if you have a windmill turning a propeller on a boat if you could sail into the wind? I can kind of make an argument that it would go backwards, stay in one place, or go forward so I guess an experiment maybe with a scale model would have to be done...

## Monday, February 15, 2016

### Perfect pivot quick sort

Suppose you have n items to be sorted, for example:
3,7,15,4,8,2,9,13,11,10,6,12,1,0,14,5
The first step is to take the first four items from the list and arrange them in 2 pairs, so that the least and greatest of the four numbers is the first pair and the two in between are the next pair like so:
3,15
4,7
Now the repeating step is to take the next 2 items from the list and arrange the 3 pairs so the six items are in order reading down the left items then up the right like so:
3,15
4,7
becomes
2,15
3,8
4,7 because these six items in order are 2,3,4,7,8,15
Now we can start a pile with 2 and 15 in it, and our four new numbers are just:
3,8
4,7
and repeat until all the numbers are exhausted for example it continues:
3,8
4,7
to get
3,13
4,9
7,8
then the 3 and the 13 join the piles so you have 2,15,3,13 and the four new numbers are:
4,9
7,8
to which you add 11,10 to get:
4, 11
7, 10
8, 9
and 4 and 11 get put onto the pile in progress to have 2,15,3,13,4,11

Now you can see that our bottom two number numbers must eventually be the median numbers of the set because every step found a number less and a number greater than them, and the pile can split in two for items less or greater than those two, this means you will have the perfect pivot to recursively apply the algorithm to the two halves!

## Sunday, February 7, 2016

### Maximizing CD Vector Magnitude Minimizes Length of Path through points

First defining some terms and a hypothesis for closed paths P on the plane through n points with x,y coordinates x[i], y[i] all in the first quadrant:
c and d so named because they are the cross and dot products of vectors from the origin to successive points on the path, and l is the sum of the lengths of the lines between successive points on the path each squared...

For example I plotted c,d values for the 720 possible closed paths through 7 random points all with the same starting point and got:

P[1] and P[-1] were the two solutions to the travelling salesman problem, or paths minimizing l through the points with the starting point fixed, and they also were the two points that maximized c^2+d^2, P[-1] being just P[1] traversing the points in reverse order...

**It looked to me even more generally decreasing c^2 +d^2 increased l proportionally but I'll have to investigate further**

## Friday, January 29, 2016

### within 6% Vector Coordinate Interpolation

For n points in any number of dimensions with coordinates P(n),
The function above interpolates the points within an error range of about 6% of the magnitude of the vector to each point... P(0) in the graph below is A, P(1) is B, up to P(6) being A again...
The above is 5 points of 2d vectors being interpolated... The nice thing about this formula is it applies to any number of points in any number of dimensions...

It goes very nearly through the midpoints between each pair of successive vertices, I think changing the e values in the formula to possibly two different numbers might be able to close in closer to the given points but maybe at the expense of not going as nicely through the midpoints...

The term inside the sum multiplying with the point vector is a normal distribution, with a value of 1 at a particular integer t value and tapering off on each side so that it's roughly 1/2 at the half integers on either side. The ideal would be a distribution with a peak of 1 at an integer t value and a value of exactly 1/2 at each half integer on either side and going completely to 0 everywhere at the integers on either side and beyond, but I think that's only really possible to approximate with a closed form function... Also if you go all the way to a triangular distribution over the interval so you make perfectly the polygon including the points you lose the nice property that the derivative is defined continuously everywhere...

## Sunday, January 24, 2016

### Vector Coordinate Parameterized Ellipse in Triangle

The traced curve varying t goes through the midpoints of the sides of the triangle...

## Wednesday, January 20, 2016

### sphere to modular plane

I was thinking some problems that take place on a sphere might be easier thinking of them on the modular plane and some modulo problems might be easier thinking of them on a sphere...

## Friday, January 15, 2016

### Point in convex polygon by coefficients times vertices

Supposing you have n vertices in the plane forming a convex region chosen to be indexed in some order by i, I found that any point inside that convex polygon can be expressed as the sum of coefficients [0..1] multiplying each vertex with coefficients adding to 1...

For example if the vertices were V[0], V[1], V[2], V[3], V[4], a point inside the polygon will be

.2*V[0]+.4*V[1]+.2*V[2]+.1*V[3]+.1*V[4]

Note that the coefficients add to 1 and are between inclusive 0 and 1!

I wrote this program to demonstrate. This is plotting points for any coefficients meeting these two criteria in 20 discrete steps between 0 and 1 inclusive and 5 vertices...

I've made it so c[0] makes a plotted point redder proportional to how large the coefficient is...

Below is with 50 discrete values between 0 and 1 of the variables:

I think it's clear with fine enough steps every part of the pentagon would be plotted, perhaps uniquely...

I'm still working on a proof though... I wrote the program just to see if it obviously wasn't true but it looks like it is...

#### **Source Code requires Python 3 and Pillow for Python**

from PIL import Image

def descend(n, c, i, s, d, plot, coords):
if i < n-1:
m = 1.0
while(m >= -d/2.0):
c[i] = m
if(s+m <=1-d/2.0):
descend(n, c, i+1, s+m, d, plot, coords)
m -= d
else:
c[n-1] = 1.0-s
print(c)
p = [0,0]
for j in range(0, n):
p[0] += c[j]*coords[j][0]
p[1] += c[j]*coords[j][1]
plot.putpixel((int(p[0]), int(p[1])), (255,255-int(c[0]*255),255-int(c[0]*255)))

def main():
coords = [[84,232],[104, 424],[342,508],[528,276],[330,212]]
plot = Image.new("RGB", [800,800])
c = [0,0,0,0,0]
descend(5, c, 0, 0, .05, plot, coords)
plot.save("plot.png")
main()

### recursive cosine square wave?

This recursive function might eventually go to a square wave...

## Thursday, January 14, 2016

### Parallel convex hull algorithm #2

So supposing you have points on the plane with known coordinates...:
First find the centroid (marked in red) and the four points with extreme values of x and y coordinates...
Any point inside the triangles formed can be removed...
Now the recursive step is to find from the centroid  lines dividing each triangle into two pieces such that the point the line ends on is the farthest from the centroid within that section like so:

Now form triangles and remove points again...
In this case we were already done with thte last lines added forming the convex hull...
But the process may need to be iterated until all remaining points are on the polygon...

It may be useful to use polar coordinates centered at the centroid then the points can be sorted by theta and easily split into sections and the furthest point would be the point with the largest r value in each section...I think it should then be fairly straightforward to extend it to 3 dimensions using spherical coordinates instead...

## Thursday, January 7, 2016

### Notation for Direction and Distance plots on Cartesian plane

I will be considering these two formulas which are good for modelling a situation when you know the angle you want the plot to go in with respect to the x axis from a point and how far in that direction for each of n discrete steps...
With the meaning that X(n), Y(n) is the nth point in a series...

And to show with an example first let L(i) = i and theta(i) = i*2*pi/5
Interestingly Maple knew the closed form, but it's not necessary for a limited number of points, it does make it easy to plug in any value of n and find the point without knowing any of the previous points though...

And we can make a list over n=1, 2, 3,4,5
And we can let the initial point be [0,0] to get:
An then plotting the above, both with natural number n and continuous n:

In general L(i) can be any discrete function of length of lines for the plot and theta(i) can be any function for the angle the lines make with the x axis...

**Next is to see what happens when L(i) is a constant with a delta->0 length and theta(i) gets more continuous