Nsolvejs
Introduction
(Before JNsolve)Solve numerically equations and calculate best fit to a data array given, also provides a series of numeric routines usable.
Installation
$ npm install Nsolvejs
Features
- Nsolvejs statistical
- Nsolvejs bestfit
- Nsolvejs regulafalsi
- Nsolvejs fixedpoint
- Nsolvejs bisection
- Nsolvejs Newton-Raphson
- Nsolvejs Newton-Raphson-Higher-Order
- Nsolvejs Numerical Derivative
- Nsolvejs FindRoot
API
Nsolvejs
Initialize Nsolvejs
var Nsolvejs = ;
Numerical analysis
Nsolvejs.calculusN.D
Object with differents numerics methods to calculate the derivative of a function.
Nsolvejs.calculusN.D.NumericalDerivateof(Function,Number,Array)
Constructor that generates the numeric derivative of Function
=> f(x) with a Number
=> N given of divisions in an interval Array
=> [a,b].
NsolvejsD
Nsolvejs.calculusN.D.NumericalDerivateof.f_x
Instance method what is the derivative numerical of Function
with a Number
given of divisions in an interval Array
.
NsolvejsD
is a aproximation to the derivative of f (df_dx) on 3 with the 1000 divisions in the interval [2,7]. Is available another method that calculate the numerical derivative calculating the dx_i in a optimazed way, dx_i=h/sqrt(1+dfdx^2) with h=(b-a)/N.
Nsolvejs.calculusN.D_opt.NumericalDerivateof(Function,Number,Array)
Nsolvejs.calculusN.D_opt.NumericalDerivateof.f_x
Nsolvejs.calculusN.D.linear_interpolation(Array)
Is a constructor that generates the numeric linear interpolation of data given in Array
= [[x_1,y_2],[x_2,y_3],...[x_n,y_n]] in the interval [x_1,x_n].
array_to_interpolate = 032146251469 ;NsolvejscalculusND
Nsolvejs.calculusN.D.linear_interpolation(Array).function_interpolated
Is a instance method what is the interpolated function of Array
given.
NsolvejsD
Is a aproximation interpolated to the Array
= [[0,3.2],[1,4.6],[2,5.1],[4,6.9]].
Nsolvejs.nsolveqn(Function, Array[,Number,Object])
Is a method that calculate numerically the solution of Function
=>f(x)=0 try in the interval (Array
=>[a,b]) beginning on Number
=>x_0 (initial point).
{ return x-Math ;}Nsolvejs = 073952
The Object
is default options and are { npointsDNumeric : 1000, presicion : 0.001 , nstepsmax : 1000 , method : 'Newton_Rapshon' }. The mothods available are RegulaFalsi, bisection,fixedpoint,Newton_Raphson_Higherorder, Newton_Raphson. The rest of routines for every method are availables:
Nsolvejs.calculusN.RegulaFalsi(Function,Array[,Object])
Nsolvejs.calculusN.bisection(Function, Array[,Object])
Nsolvejs.calculusN.fixedpoint(Function,Number[,Object])
Nsolvejs.calculusN.Newton_Raphson(Function,Array[, Number, Object])
Nsolvejs.calculusN.Newton_Raphson_Higherorder(Function,Array[, Number, Object])
in every case if x_0 is undefined, is taken from a random number in interval Array
=>[a,b]. All these methods return a object with properties Root, numSteps and method used.
Nsolvejs.calculusN.findroot(Function, Array[,Number,Object])
Is a method that calculate numerically the solution of Function
=>f(x)=0 try in the interval (Array
=>[a,b]) beginning on Number
=>x_0 (initial point).
NsolvejscalculusN = 073952
The Object
is default options and are { npointsDNumeric : 1000, precision : 0.001 , nstepsmax : 1000 , method : 'Newton_Rapshon' }. Here, findroot try find the root of function by all methods availables in the module.
Data Fitting
Nsolvejs.fit.best(Array[,Array,Array,Object,Function])
Calculate the best fit using the first Array
= [[x_1,y_1,z_1...],[x_2,y_2,z_2...],...[x_n,y_n,z_n,...]] argument as data input (if the fit is already calculated before you can pass it instead), the second Array
= [z_1,z_2...z_m] argument are the values of x's for which is necessary calculate their y`s values respectively, the third argument are the values of "y" for which is queried the values of "x". The properties of options object are smoothing (default = True), noiseeliminate (default = True), smoothingmethod (default ='exponential' only by moment), alpha (default = 0.8) and fits_name (the fits function) to use: the availables function are inverse (a/(b+x)), linear (ax+b), exponential (a_e^(bx)), logarithmic (a+b Log(x)), polynomial (ax^2+bx+c), sqrt (a_ sqrt(x)+b) and power (ax^b), if not specified take all function availables, using (array) property specified which column of data in Array is taken to do the fist. The noiseeliminate method eliminate data that are beyond of 3.5 standard deviation from mean(99.95 % Reliability if data have a normal distribution), does that make a loop filter until that not one data is out of this limit. Return a object with the properties: ans_ofY,ans_ofX, fitUsed, fitEquationUsed, fitParamsUsed, fitPointsUsed, fitWithError and fit. The last parameter is a callback function that receive as only parameter the fit self.
array_to_fit =04401-2483956412070;array_of_x = 34 48 8 11 ;array_of_y = 758399105;Nsolvejs; fit = ans_ofY: 34 6141945099444754 48 7793133160533434 8 20214957607090903 11 -4089420392173956 ans_ofX: 4596464057224314 75 5118019106548409 83 5908254029766733 99 6142502239149309 105 fitOptions: smoothing: true noiseeliminate: false smoothingmethod: 'exponential' alpha: 09 fits_name: 'sqrt' 'inverse' using: 0 2 fitUsed: 'inverse' fitEquationUsed: 'y = -405.84/(x - 10.01)' fitParamsUsed: -4058350227553108 -10007597693961792 fitPointsUsed: 0 40 1 472 3 5512 4 68512 fitWithError: 205844894339866 fit: sqrt: regression: Object error: 34369281428656664 inverse: regression: Object error: 205844894339866 best: name: 'inverse' error: 205844894339866 f: Function
Contributing
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code. For any bugs report please contact to me via e-mail: jesus.edelcereceres@gmail.com.
Licence
The MIT License (MIT)
Copyright (c) Jesus Cereceres all the related trademarks.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.