Comparing version 0.7.9 to 0.7.10
@@ -26,3 +26,3 @@ /* | ||
var __ = core.Extra = { | ||
version: '1.0.0', | ||
version: '1.1.0', | ||
//http://integral-table.com/downloads/LaplaceTable.pdf | ||
@@ -96,6 +96,7 @@ LaPlace: { | ||
var sym = symbol.sub(t, u); | ||
retval = core.Calculus.integrate(_.parse('e^(-'+s+'*'+u+')*'+sym), u); | ||
var integration_expr = _.parse('e^(-'+s+'*'+u+')*'+sym); | ||
retval = core.Calculus.integrate(integration_expr, u); | ||
if(retval.hasIntegral()) | ||
_.error('Unable to compute transform'); | ||
retval = retval.sub(u, 0); | ||
retval = retval.sub(t, 0); | ||
retval = _.expand(_.multiply(retval, new Symbol(-1))); | ||
@@ -102,0 +103,0 @@ retval = retval.sub(u, t); |
export as namespace nerdamer | ||
export = nerdamer | ||
declare function nerdamer( | ||
expression: string, | ||
expression: nerdamer.ExpressionParam, | ||
subs?: { [name: string]: string }, | ||
@@ -9,4 +9,5 @@ option?: keyof nerdamer.Options | (keyof nerdamer.Options)[], | ||
declare namespace nerdamer { | ||
export type ExpressionParam = Expression | string | ||
export interface Options { | ||
numer, expand | ||
numer: never, expand: never | ||
} | ||
@@ -24,3 +25,3 @@ type int = number | ||
*/ | ||
export function setConstant(name: string, value: number | string): void | ||
export function setConstant(name: string, value: number | string): typeof nerdamer | ||
@@ -40,3 +41,3 @@ /** | ||
*/ | ||
export function setFunction(function_name: string, param_array: string[], function_body: string): void | ||
export function setFunction(function_name: string, param_array: string[], function_body: string): typeof nerdamer | ||
@@ -65,3 +66,3 @@ /** | ||
*/ | ||
export function flush(): void | ||
export function flush(): typeof nerdamer | ||
@@ -136,3 +137,3 @@ /** | ||
*/ | ||
export function register(f: ModuleFunction | ModuleFunction[]): void | ||
export function register(f: ModuleFunction | ModuleFunction[]): typeof nerdamer | ||
@@ -170,3 +171,3 @@ /** | ||
*/ | ||
export function clearVars(): void | ||
export function clearVars(): typeof nerdamer | ||
@@ -189,4 +190,5 @@ /** | ||
*/ | ||
export function set(setting: 'PARSE2NUMBER', value: boolean): void | ||
export function set(setting: 'IMAGINARY', value: string | 'i'): void | ||
export function set(setting: 'PARSE2NUMBER', value: boolean): typeof nerdamer | ||
export function set(setting: 'IMAGINARY', value: string | 'i'): typeof nerdamer | ||
export function set(setting: 'POWER_OPERATOR', value: '**' | '^'): typeof nerdamer | ||
@@ -253,3 +255,6 @@ export interface Expression { | ||
*/ | ||
export function sum(expression: string, index: string, lower: string, upper: string) | ||
export function sum(expression: ExpressionParam, | ||
index: string, | ||
lower: ExpressionParam, | ||
upper: ExpressionParam): Expression | ||
@@ -261,3 +266,3 @@ /** | ||
*/ | ||
export function integrate(expression: string, variable: string): Expression | ||
export function integrate(expression: ExpressionParam, variable: string): Expression | ||
@@ -270,3 +275,3 @@ /** | ||
*/ | ||
export function diff(expression: string, variable: string, n?: int): Expression | ||
export function diff(expression: ExpressionParam, variable: string, n?: int): Expression | ||
@@ -279,3 +284,3 @@ ////////// ALGEBRA | ||
*/ | ||
export function divide(expression: string): Expression | ||
export function divide(expression: ExpressionParam): Expression | ||
@@ -286,3 +291,3 @@ /** | ||
*/ | ||
export function factor(expression: string): Expression | ||
export function factor(expression: ExpressionParam): Expression | ||
@@ -293,3 +298,3 @@ /** | ||
*/ | ||
export function gcd(expression: string): Expression | ||
export function gcd(expression: ExpressionParam): Expression | ||
@@ -300,3 +305,3 @@ /** | ||
*/ | ||
export function factor(expression: string): Expression | ||
export function factor(expression: ExpressionParam): Expression | ||
} |
@@ -9,3 +9,3 @@ { | ||
"license": "MIT", | ||
"version": "0.7.9", | ||
"version": "0.7.10", | ||
"homepage": "http://nerdamer.com/", | ||
@@ -55,2 +55,2 @@ "directory": { | ||
} | ||
} | ||
} |
30
Solve.js
@@ -32,5 +32,7 @@ /* | ||
core.Solve = { | ||
version: '1.2.1', | ||
version: '1.2.2', | ||
solve: function(eq, variable) { | ||
return new core.Vector(solve(eq.toString(), variable ? variable.toString() : variable)); | ||
var solution = solve(eq, String(variable)); | ||
return new core.Vector(solution); | ||
//return new core.Vector(solve(eq.toString(), variable ? variable.toString() : variable)); | ||
} | ||
@@ -202,3 +204,4 @@ }; | ||
var det = _.pow(bsqmin4ac, Symbol(0.5)); | ||
return _.divide(_[plus_or_minus](b.clone().negate(), det),_.multiply(new Symbol(2), a.clone())); | ||
var retval = _.divide(_[plus_or_minus](b.clone().negate(), det),_.multiply(new Symbol(2), a.clone())); | ||
return retval; | ||
}; | ||
@@ -230,3 +233,3 @@ | ||
'-(b/(3*a))-C/(3*a)-(((b^2-3*a*c))/(3*a*C))', | ||
'-(b/(3*a))+(C*(1+i*sqrt(3)))/(6*a)+((1-i*sqrt(3))*(b^2-3*a*c))/6*a*C'.replace(/i/g, core.Settings.IMAGINARY), | ||
'-(b/(3*a))+(C*(1+i*sqrt(3)))/(6*a)+((1-i*sqrt(3))*(b^2-3*a*c))/(6*a*C)'.replace(/i/g, core.Settings.IMAGINARY), | ||
'-(b/(3*a))+(C*(1-i*sqrt(3)))/(6*a)+((1+i*sqrt(3))*(b^2-3*a*c))/(6*a*C)'.replace(/i/g, core.Settings.IMAGINARY) | ||
@@ -289,3 +292,3 @@ ]; | ||
*/ | ||
var solve = function(eqns, solve_for, solutions) { | ||
var solve = function(eqns, solve_for, solutions) { | ||
solve_for = solve_for || 'x'; //assumes x by default | ||
@@ -297,2 +300,16 @@ //If it's an array then solve it as a system of equations | ||
solutions = solutions || []; | ||
//maybe we get lucky | ||
if(eqns.group === S && eqns.contains(solve_for)) { | ||
solutions.push(new Symbol(0)); | ||
return solutions; | ||
} | ||
if(eqns.group === CB) { | ||
var sf = String(solve_for); //everything else belongs to the coeff | ||
eqns.each(function(x) { | ||
if(x.contains(sf)) | ||
solve(x, solve_for, solutions); | ||
}); | ||
return solutions; | ||
} | ||
var existing = {}, //mark existing solutions as not to have duplicates | ||
@@ -567,5 +584,7 @@ add_to_result = function(r, has_trig) { | ||
parent: 'Solve', | ||
numargs: 2, | ||
visible: true, | ||
build: function(){ return core.Solve.solve; } | ||
}, | ||
/* | ||
{ | ||
@@ -577,2 +596,3 @@ name: 'polysolve', | ||
}, | ||
*/ | ||
{ | ||
@@ -579,0 +599,0 @@ name: 'setEquation', |
@@ -269,3 +269,3 @@ 'use strict'; | ||
// with xit (instead of it), a test can be disabled temporarily | ||
xit('should factor correctly', function () { | ||
it('should factor correctly', function () { | ||
// given | ||
@@ -276,12 +276,18 @@ var testCases = [ | ||
expected: '(1+x)^2' | ||
}, { | ||
}, | ||
{ | ||
given: 'factor(x^4+25*x^3+234*x^2+972*x+1512)', | ||
expected: '(6+x)^3*(7+x)' | ||
}, { | ||
}, | ||
{ | ||
given: 'factor(x^5+32*x^4+288*x^3-418*x^2-16577*x-55902)', | ||
expected: '(-7+x)*(11+3*x+x^2)^3*(6+x)' | ||
}, { | ||
expected: '(-7+x)*(11+x)^3*(6+x)' | ||
}, | ||
/* | ||
//TODO: This should factor as well | ||
{ | ||
given: 'factor(x^2*y*z+x*z+t*x^2*y+t*x)', | ||
expected: '(1+x*y)*(t+z)*(x)' | ||
} | ||
*/ | ||
]; | ||
@@ -297,2 +303,36 @@ | ||
}); | ||
it('should get coeffs', function () { | ||
// given | ||
var testCases = [ | ||
{ | ||
given: 'coeffs(x^2+2*x+1, x)', | ||
expected: '[1,2,1]' | ||
}, | ||
{ | ||
given: 'coeffs(a*b*x^2+c*x+d, x)', | ||
expected: '[d,c,a*b]' | ||
}, | ||
{ | ||
given: 'coeffs(t*x, x)', | ||
expected: '[0,t]' | ||
}, | ||
{ | ||
given: 'coeffs(b*(t*x-5), x)', | ||
expected: '[-5*b,b*t]' | ||
}, | ||
{ | ||
given: 'coeffs(a*x^2+b*x+c+x, x)', | ||
expected: '[c,1+b,a]' | ||
} | ||
]; | ||
for (var i = 0; i < testCases.length; ++i) { | ||
// when | ||
var result = nerdamer(testCases[i].given); | ||
// then | ||
expect(result.toString()).toEqual(testCases[i].expected); | ||
} | ||
}); | ||
}); |
@@ -419,3 +419,27 @@ 'use strict'; | ||
expected: '-sinh(x)+cosh(x)*x' | ||
} | ||
}, | ||
{ | ||
given: 'integrate((x^6+x^2-7)/(x^2+11), x)', | ||
expected: '(-11/3)*x^3+(1/5)*x^5+122*x-1349*atan(sqrt(11)^(-1)*x)*sqrt(11)^(-1)' | ||
}, | ||
{ | ||
given: 'integrate(x^6/(x^2+11), x)', | ||
expected: '(-11/3)*x^3+(1/5)*x^5+121*x-1331*atan(sqrt(11)^(-1)*x)*sqrt(11)^(-1)' | ||
}, | ||
{ | ||
given: 'integrate(x^2/(x^2+11))', | ||
expected: '-11*atan(sqrt(11)^(-1)*x)*sqrt(11)^(-1)+x' | ||
}, | ||
{ | ||
given: 'integrate(tan(x)*csc(x), x)', | ||
expected: 'log(sec(x)+tan(x))' | ||
}, | ||
{ | ||
given: 'integrate(sinh(x)*e^x, x)', | ||
expected: '(-1/2)*x+(1/4)*e^(2*x)' | ||
}, | ||
{ | ||
given: 'integrate(sinh(x)*cos(x), x)', | ||
expected: '(-1/4)*e^(-x)*sin(x)+(1/4)*cos(x)*e^(-x)+(1/4)*cos(x)*e^x+(1/4)*e^x*sin(x)' | ||
}, | ||
]; | ||
@@ -422,0 +446,0 @@ |
@@ -224,2 +224,7 @@ 'use strict'; | ||
{ | ||
given: '0^(1/2)', | ||
expected: '0', | ||
expectedValue: '0' | ||
}, | ||
{ | ||
given: '2^(1/2)', | ||
@@ -762,3 +767,4 @@ expected: 'sqrt(2)', | ||
expected: '(-x)^x*2^x*3^(-x)', | ||
expectedValue: '1.9278587+0.626399264*i' | ||
//TODO: Evaluates to NaN somewhere | ||
expectedValue: '(-1)^(21/10)*5^(-21/10)*7^(21/10)' | ||
} | ||
@@ -765,0 +771,0 @@ ]; |
@@ -62,2 +62,6 @@ 'use strict'; | ||
expected: '-2*(-s+a)^(-3)' | ||
}, | ||
{ | ||
given: 'laplace(sinh(t)*e^t, t, s)', | ||
expected: '(1/2)*(-s+2)^(-1)+(1/2)*s^(-1)' | ||
} | ||
@@ -64,0 +68,0 @@ ]; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
665019
22
14881
1