pn.Min( [ 13, 22, 26, 38, 36, 42 ] ); // Returns - 13
pn.Max( [ 49, 50, 77, 81, 98, 110 ] ); // Returns - 110
// Range = Max - Min
pn.Range( [ 49, 50, 77, 81, 98, 110 ] ); // Returns - 61
pn.AFrequency( [ 11, 2, 45, 5, 3, 2, 4, 11, 4, 3, 5 ] , 2 );
// Returns - { Value: 2 , Occurance: 2 }
pn.SomeFrequencies( [ 11, 2, 45, 5, 3, 2, 4, 11, 4, 3, 5 ] , [ 4, 2 ] );
// Returns - [ { Value: 4 , Occurance: 2 } , { Value: 2 , Occurance: 2 } ]
pn.AllFrequencies( [ 11, 2, 45, 5, 3, 2, 4, 11, 4, 3, 5 ] );
// Returns - Frequencies of all the Numbers
pn.Mean( [ 11, 2, 45, 5, 3, 2, 4, 11, 4, 3, 5 ] );
// Returns - 8.63
pn.Median( [ 11, 2, 45, 5, 3, 2, 4, 11, 4, 3, 5 ] );
// Returns - 4
pn.Mode( [ 11, 2, 45, 5, 3, 2, 4, 11, 4, 3, 5 ] );
// Returns - 11
pn.SampleStandardDeviation( [ 11, 2, 45, 5, 3, 2, 4, 11, 4, 3, 5 ] );
// Returns - 12.46
pn.PopulationStandardDeviation( [ 11, 2, 45, 5, 3, 2, 4, 11, 4, 3, 5 ] );
// Returns - 11.88
pn.MeanAbsoluteDeviation( [ 11, 2, 45, 5, 3, 2, 4, 11, 4, 3, 5 ] );
// Returns - 7.47
pn.MedianAbsoluteDeviation( [ 11, 2, 45, 5, 3, 2, 4, 11, 4, 3, 5 ] );
// Returns - 2
All Operations also work with Scalars
const m1 = pn.matrix([
[1000,2000,3000,4000],
[100,200,300,400]
]);
const m1 = pn.matrix([
[1000,2000,3000,4000],
[100,200,300,400]
]);
const m2 = pn.matrix([
[100,200,300,400],
[1000,2000,3000,4000]
]);
const m3 = m1.add(m2); // Returns a New Matrix
const m1 = pn.matrix([
[10,20],
[100,200]
]);
const m2 = pn.matrix([
[100,200,300,400],
[1000,2000,3000,4000]
]);
const m3 = m1.subtract(m2); // Returns a New Matrix
const m1 = pn.matrix([
[1,2],
[10,20]
]);
const m2 = pn.matrix([
[5,10],
[50,100]
]);
const m3 = m1.multiply(m2); // Returns a New Matrix
const m1 = pn.matrix([
[10,20],
[30,40],
[50,60]
])
const m2 = pn.matrix([
[10,20,30],
[40,50,60]
])
const m3 = m1.dot(m2); // Returns a New Matrix
const m1 = pn.matrix([
[1,2],
[10,20]
]);
const m2 = pn.matrix([ 2 , 20 ]);
const m3 = m1.divide(m2); // Returns a New Matrix
const m1 = pn.matrix([
[10,20],
[30,40],
[50,60]
]);
m1.at(1,1,100); // It will change 10 -> 100
const m1 = pn.matrix([
[10,20],
[30,40],
[50,60]
]);
const m2 = m1.map(e => e ** 2); // It will return a new Matrix
const m1 = pn.matrix([
[10,20],
[30,40],
[50,60]
]);
const m2 = m1.transpose(); // Returns a New Matrix
const m1 = pn.matrix([
[1,2],
[10,20]
]);
const m2 = m1.clone(); // Returns a New Matrix
const m1 = pn.matrix([
[10,20],
[30,40],
[50,60]
]);
m1.randomize(0,10); // Will choose a random value from 0 to 10 for all the elements of the Matrix
m1.randomize(); // By Default range is from -1 to 1
const m1 = pn.matrix([
[10,20],
[30,40],
[50,60]
]);
let am1 = m1.flatten(); // It will flatten the Matrix to [10,20,30,40,...] and return the Array
const m1 = pn.matrix([
[10,20],
[30,40],
[50,60]
]);
let am1 = m1.flatMap( e => e * 2 );
// It will flatten [10,20,30,40,...] and then apply the operation to each element [20,40,60,80,...] and return the Array
const m1 = pn.matrix([
[9,3,5],
[-6,-9,7],
[-1,-8,1]
]);
let min = m1.minor(1,1); // will return a minor matrix
const m1 = pn.matrix([
[9,3,5],
[-6,-9,7],
[-1,-8,1]
]);
let cf = m1.cofactor(1,2); // will return the cofactor value
const m1 = pn.matrix([
[5,7],
[10,20]
]);
let det = m1.determinant(); // will return the determinant
const m1 = pn.matrix([
[9,3,5],
[-6,-9,7],
[-1,-8,1]
]);
let inv = m1.inverse(); // will return and inverse matrix and may contain decimal values
const m1 = pn.matrix([
[9,3,5],
[-6,-9,7],
[-1,-8,1]
]);
let inv = m1.inverse2(); // will return and inverse matrix of fractions
const m1 = pn.matrix([
[9,3,5],
[-6,-9,7],
[-1,-8,1]
]);
console.log(m1.toString()); // will print the Matrix in a formatted fashion
const m1 = pn.vector([ 10, 20, 30 ]);
const m1 = pn.colVector([ 10, 20, 30 ]);
const f1 = pn.fraction(2,7);
const f1 = pn.fraction(3,9);
console.log(f1.toString());
const f1 = pn.fraction(5,2);
const f2 = pn.fraction(7,3);
const f3 = f1.add(f2);
console.log(f3.toString());
const f1 = pn.fraction(4,3);
const f2 = pn.fraction(8,9);
const f3 = f1.substract(f2);
console.log(f3.toString());
const f1 = pn.fraction(5,2);
const f2 = pn.fraction(4,8);
const f3 = f1.multiply(f2);
console.log(f3.toString());
const f1 = pn.fraction(5,10);
const f2 = pn.fraction(2,5);
const f3 = f1.divide(f2);
console.log(f3.toString());
const f1 = pn.fraction(25,50);
console.log(f1.reduce().toString());
const rf = recurringToFraction(1,undefined,3); // represents 1.33333333...
// First parameter is digits before the dot
// Second parameter is non-recurring digits after the dot if not pass undefined
// Third parameter is recurring digits after the dot
console.log(rf.toString());
const c1 = pn.complex(10,2); // 10(Real) , 2(Coefficient of i)
const c1 = pn.complex(10,2);
console.log(c1.toString()); // -> 10 + 2i
const c1 = pn.complex(10,2);
const c2 = pn.complex(5,3);
console.log(c1.add(c2).toString());
const c1 = pn.complex(10,2);
const c2 = pn.complex(5,3);
console.log(c1.substract(c2).toString());
const c1 = pn.complex(5,7);
const c2 = pn.complex(-6);
console.log(c1.multiply(c2).toString());
const c1 = pn.complex(5,10);
console.log(c1.divide(2).toString());
const c1 = pn.complex(5,10);
console.log(c1.pow(2).toString());
const c1 = pn.complex(4,4);
console.log(c1.sqrt().toString());
const c1 = pn.complex(4,4);
console.log(c1.exp().toString());
const c1 = pn.complex(10,10);
console.log(c1.log().toString());
const c1 = pn.complex(8,9);
console.log(c1.sin().toString());
const c1 = pn.complex(1,7);
console.log(c1.cos().toString());
const c1 = pn.complex(8,9);
console.log(c1.sinh().toString());
const c1 = pn.complex(1,7);
console.log(c1.cosh().toString());
const c1 = pn.complex(6,2);
console.log(c1.angle());
const c1 = pn.complex(-5,10);
console.log(c1.mod().toString());
const c1 = pn.complex(5,10);
console.log(c1.conjugate().toString());
const c1 = pn.complex(5,10);
console.log(c1.addinv().toString());
const c1 = pn.complex(5,10);
console.log(c1.mulinv().toString());
const c1 = pn.complex(5,10);
console.log(c1.toArray());
const y = pn.oscillatorWave({
amplitude:0.5,
period:3.2
});
console.log(y.of(4));
const z = pn.wave({
amplitude:3,
wavelength:4,
period:8,
start:3
});
console.log(z.of(2,1));
const z = pn.wave({
amplitude:3,
wavelength:4,
period:8,
start:3
});
// You can pass variable number of waves as paramenters while calling superimpose
const sz = z.superimpose(z);
// superimpose method returns a Superposition Object which will be internally an amalgamation of all the waves imposed on the original wave
// Superposition Object internally keeps a list with references to all the waves of which then combine to create Superposition. Superposition follows the same protocol/interface as Wave so it can be used in a composite fashion shown in the next example
// Will amplify the original wave by the factor of 2
console.log(sz.of(2,1));
const x = pn.wave({
amplitude:3,
wavelength:4,
period:8,
start:3
});
const sx = x.superimpose(x); // Will amplify the original wave by the factor of 2
const z = pn.wave({
amplitude:5,
wavelength:2,
period:4,
start:5
});
const sz = z.superimpose(z,sx); // Can also pass Superpositions Instances
console.log(sz.of(2,1));
const w1 = pn.wave({
amplitude:3,
wavelength:4,
period:8,
start:1
});
const w2 = pn.wave({
amplitude:3,
wavelength:4,
period:8,
start:1,
shift:180
});
const sw = w1.superimpose(w1,w1,w2);
const w3 = pn.wave({
amplitude:5,
wavelength:2,
period:3,
start:1
});
const ssw = w3.superimpose(w3,sw);
console.log(ssw.of(2,0)); // It will be 3 + 3 + 3 - 3 + 5 + 5 = 16 ( Adding the Amplitudes )