Comparing version 0.8.2 to 0.8.3
@@ -12,3 +12,3 @@ /* | ||
if((typeof module) !== 'undefined') { | ||
nerdamer = require('./nerdamer.core.js'); | ||
var nerdamer = require('./nerdamer.core.js'); | ||
require('./Calculus'); | ||
@@ -15,0 +15,0 @@ require('./Algebra'); |
@@ -9,3 +9,3 @@ { | ||
"license": "MIT", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"homepage": "http://nerdamer.com/", | ||
@@ -12,0 +12,0 @@ "directory": { |
49
Solve.js
@@ -10,3 +10,3 @@ /* | ||
if((typeof module) !== 'undefined') { | ||
nerdamer = require('./nerdamer.core.js'); | ||
var nerdamer = require('./nerdamer.core.js'); | ||
require('./Calculus.js'); | ||
@@ -51,2 +51,4 @@ require('./Algebra.js'); | ||
core.Settings.make_pi_conversions = true; | ||
// The step size | ||
core.Settings.STEP_SIZE = 0.1; | ||
@@ -260,5 +262,16 @@ core.Symbol.prototype.hasTrig = function() { | ||
var result = m.multiply(c); | ||
var solutions = []; | ||
//correct the sign as per issue #410 | ||
if(core.Utils.isArray(var_array)) | ||
result.each(function(x) { | ||
return x.negate(); | ||
}); | ||
var solutions = core.Settings.SOLUTIONS_AS_OBJECT ? {} : []; | ||
result.each(function(e, idx) { | ||
solutions.push([vars[idx], (expand_result ? _.expand(e) : e).valueOf()]); | ||
var solution = (expand_result ? _.expand(e) : e).valueOf(); | ||
var variable = vars[idx]; | ||
if(core.Settings.SOLUTIONS_AS_OBJECT) { | ||
solutions[variable] = solution; | ||
} | ||
else | ||
solutions.push([variable, solution]); | ||
}); | ||
@@ -395,3 +408,4 @@ //done | ||
var get_points = function(symbol) { | ||
var get_points = function(symbol, step) { | ||
step = step || 0.1; | ||
var f = build(symbol); | ||
@@ -414,4 +428,4 @@ var start = Math.round(f(0)), | ||
// will miss the zeros because it will jump right over it. Think of a case where this can happen. | ||
for(var i=start; i<core.Settings.SOLVE_RADIUS; i++){ | ||
var val = f(i*0.1), | ||
for(var i=start; (i)<core.Settings.SOLVE_RADIUS; i++){ | ||
var val = f(i*step), | ||
sign = val/Math.abs(val); | ||
@@ -476,7 +490,9 @@ if(isNaN(val) || !isFinite(val) || points.length > rside) | ||
//if the lhs = x then we're done | ||
if(eqns.LHS.equals(solve_for)) | ||
if(eqns.LHS.equals(solve_for) && !eqns.RHS.contains(solve_for)) { | ||
return [eqns.RHS]; | ||
} | ||
//if the rhs = x then we're done | ||
if(eqns.RHS.equals(solve_for)) | ||
if(eqns.RHS.equals(solve_for) && !eqns.LHS.contains(solve_for)) { | ||
return [eqns.LHS]; | ||
} | ||
} | ||
@@ -545,3 +561,6 @@ //unwrap the vector since what we want are the elements | ||
// we get all the points where a possible zero might exist | ||
var points = get_points(symbol), | ||
var points1 = get_points(symbol, 0.1); | ||
var points2 = get_points(symbol, 0.05); | ||
var points3 = get_points(symbol, 0.01); | ||
var points = core.Utils.arrayUnique(points1.concat(points2).concat(points3)), | ||
l = points.length; | ||
@@ -751,9 +770,11 @@ //compile the function and the derivative of the function | ||
else { | ||
/* | ||
var sym_roots = csolve(eq, solve_for); | ||
if(sym_roots.length === 0) | ||
sym_roots = divnconsolve(eq, solve_for); | ||
if(sym_roots.length > 0) | ||
if(sym_roots.length > 0) | ||
add_to_result(sym_roots); | ||
else | ||
_A.proots(eq).map(add_to_result); | ||
*/ | ||
_A.proots(eq).map(add_to_result); | ||
} | ||
@@ -898,5 +919,7 @@ } | ||
return solve; //comment out to return a vector | ||
return function() { | ||
/* | ||
return function() { | ||
return core.Utils.convertToVector(solve.apply(null, arguments)); | ||
}; | ||
*/ | ||
} | ||
@@ -927,2 +950,2 @@ }, | ||
nerdamer.api(); | ||
})(); | ||
})(); |
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
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
934525
10
16777