# Distance between two points (2d)

• Point A: xa
• Point A: ya
• Point B: xb
• Point B: yb

• Distance

## Neuron type

Best algorithm has been found - locked

## Patterns

Pattern Input Output
1.
 Point A: xa: 3 Point A: ya: 5 Point B: xb: 2 Point B: yb: 1
 Distance: 4.1231
2.
 Point A: xa: 9 Point A: ya: 2 Point B: xb: 6 Point B: yb: 4
 Distance: 3.6056
3.
 Point A: xa: 3 Point A: ya: 6 Point B: xb: 8 Point B: yb: 10
 Distance: 6.4031

## Applicable neurons

• Minus (x - y)
• right angled triangle, find Hypotenuse c, given a, b
• Rounding to whole thousands of something
• Rounding to whole ten thousands of something
• equilateral polygon - Perimeter
• constant x.xxxx

## Algorithm

### Test

```/**
* Minus (x - y):
*
* @param x1 Number X
* @param x2 Number Y
* @return {Array}
*/
function neuron2(x1, x2)
{
math.config({number: 'BigNumber', precision: 64}); return [math.eval(Number(x1) + '-'+Number(x2)).toString()];
}

/**
* Multiple (x × y):
*
* @param x1 Number X
* @param x2 Number Y
* @return {Array}
*/
function neuron3(x1, x2)
{
math.config({number: 'BigNumber', precision: 64}); return [math.eval(Number(x1) + '*'+Number(x2)).toString()];
}

/**
* x to the 2 (x²): x squared
*
* @param x1 Number X
* @return {Array}
*/
function neuron7(x1)
{
var outputs = [];
outputs[0] = x1;

arr = neuron3(outputs[0], outputs[0]);
outputs[1] = arr[0];

return[outputs[1]];
}

/**
* Plus (x + y): The addition of two whole numbers is the total amount of those quantities combined.
*
* @param x1 first number
* @param x2 second number
* @return {Array}
*/
function neuron1(x1, x2)
{
math.config({number: 'BigNumber', precision: 64}); return [math.eval(Number(x1) + '+'+Number(x2)).toString()];
}

/**
* 5:
*
* @return {Array}
*/
function neuron505()
{
return [5];
}

/**
* character .:
*
* @return {Array}
*/
function neuron510()
{
return['.'];
}

/**
* Connect - two inputs:
*
* @param x1 Variable A
* @param x2 Variable B
* @return {Array}
*/
function neuron520(x1, x2)
{
return [x1.toString()+x2.toString()];
}

/**
* Half (0.5):
*
* @return {Array}
*/
function neuron522()
{
var outputs = [];

arr = neuron505();
outputs[0] = arr[0];

arr = neuron510();
outputs[1] = arr[0];

arr = neuron520(outputs[1], outputs[0]);
outputs[2] = arr[0];

return[outputs[2]];
}

/**
* x to the a  (xª): value of the number x to be the power of a
*
* @param x1 x - The base
* @param x2 a - The exponent
* @return {Array}
*/
function neuron18(x1, x2)
{
return[Math.pow(Number(x1), Number(x2))];
}

/**
* Square root (√¯):
*
* @param x1 Number X
* @return {Array}
*/
function neuron554(x1)
{
var outputs = [];
outputs[0] = x1;

arr = neuron522();
outputs[1] = arr[0];

arr = neuron18(outputs[0], outputs[1]);
outputs[2] = arr[0];

return[outputs[2]];
}

/**
* right angled triangle, find Hypotenuse c, given a, b:
*
* @param x1 a
* @param x2 b
* @return {Array}
*/
function neuron615(x1, x2)
{
var outputs = [];
outputs[0] = x1;
outputs[1] = x2;

arr = neuron7(outputs[0]);
outputs[2] = arr[0];

arr = neuron7(outputs[1]);
outputs[3] = arr[0];

arr = neuron1(outputs[3], outputs[2]);
outputs[4] = arr[0];

arr = neuron554(outputs[4]);
outputs[5] = arr[0];

return[outputs[5]];
}

/**
* 0:
*
* @return {Array}
*/
function neuron500()
{
return [0];
}

/**
* 1:
*
* @return {Array}
*/
function neuron501()
{
return [1];
}

/**
* Connect - two inputs:
*
* @param x1 Variable A
* @param x2 Variable B
* @return {Array}
*/
function neuron520(x1, x2)
{
return [x1.toString()+x2.toString()];
}

/**
* Connect - four inputs:
*
* @param x1 string A
* @param x2 string B
* @param x3 string C
* @param x4 string D
* @return {Array}
*/
function neuron565(x1, x2, x3, x4)
{
var outputs = [];
outputs[0] = x1;
outputs[1] = x2;
outputs[2] = x3;
outputs[3] = x4;

arr = neuron520(outputs[2], outputs[3]);
outputs[4] = arr[0];

arr = neuron520(outputs[1], outputs[4]);
outputs[5] = arr[0];

arr = neuron520(outputs[0], outputs[5]);
outputs[6] = arr[0];

return[outputs[6]];
}

/**
* Connect - two inputs:
*
* @param x1 Variable A
* @param x2 Variable B
* @return {Array}
*/
function neuron520(x1, x2)
{
return [x1.toString()+x2.toString()];
}

/**
* Connect - five inputs:
*
* @param x1 1
* @param x2 2
* @param x3 3
* @param x4 4
* @param x5 5
* @return {Array}
*/
function neuron651(x1, x2, x3, x4, x5)
{
var outputs = [];
outputs[0] = x1;
outputs[1] = x2;
outputs[2] = x3;
outputs[3] = x4;
outputs[4] = x5;

arr = neuron565(outputs[1], outputs[2], outputs[3], outputs[4]);
outputs[5] = arr[0];

arr = neuron520(outputs[0], outputs[5]);
outputs[6] = arr[0];

return[outputs[6]];
}

/**
* 10000:
*
* @return {Array}
*/
function neuron706()
{
var outputs = [];

arr = neuron500();
outputs[0] = arr[0];

arr = neuron501();
outputs[1] = arr[0];

arr = neuron651(outputs[1], outputs[0], outputs[0], outputs[0], outputs[0]);
outputs[2] = arr[0];

return[outputs[2]];
}

/**
* Multiple (x × y):
*
* @param x1 Number X
* @param x2 Number Y
* @return {Array}
*/
function neuron3(x1, x2)
{
math.config({number: 'BigNumber', precision: 64}); return [math.eval(Number(x1) + '*'+Number(x2)).toString()];
}

/**
* Round to an integer: round(x)
*
* @param x1 Value
* @return {Array}
*/
function neuron620(x1)
{
return[Math.round(Number(x1))]
}

/**
* Division (x ÷ y): X / Y
*
* @param x1 first number
* @param x2 second number
* @return {Array}
*/
function neuron17(x1, x2)
{
math.config({number: 'BigNumber', precision: 64}); return [math.eval(Number(x1) + '/'+Number(x2)).toString()];
}

/**
* Rounding to whole ten thousands of something:
*
* @param x1 Value
* @return {Array}
*/
function neuron705(x1)
{
var outputs = [];
outputs[0] = x1;

arr = neuron706();
outputs[1] = arr[0];

arr = neuron3(outputs[1], outputs[0]);
outputs[2] = arr[0];

arr = neuron620(outputs[2]);
outputs[3] = arr[0];

arr = neuron17(outputs[3], outputs[1]);
outputs[4] = arr[0];

return[outputs[4]];
}

/**
* Distance between two points (2d):
*
* @param x1 Point A: xa
* @param x2 Point A: ya
* @param x3 Point B: xb
* @param x4 Point B: yb
* @return {Array}
*/
function neuron658(x1, x2, x3, x4)
{
var outputs = [];
outputs[0] = x1;
outputs[1] = x2;
outputs[2] = x3;
outputs[3] = x4;

arr = neuron2(outputs[1], outputs[3]);
outputs[4] = arr[0];

arr = neuron2(outputs[2], outputs[0]);
outputs[5] = arr[0];

arr = neuron615(outputs[5], outputs[4]);
outputs[6] = arr[0];

arr = neuron705(outputs[6]);
outputs[7] = arr[0];

return[outputs[7]];
}

```