Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #591 from jiggzson/dev
Browse files Browse the repository at this point in the history
1.1.7
  • Loading branch information
jiggzson committed Feb 15, 2021
2 parents e48193a + c7c7229 commit c846f3f
Show file tree
Hide file tree
Showing 11 changed files with 512 additions and 283 deletions.
203 changes: 143 additions & 60 deletions Algebra.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions Calculus.js
Expand Up @@ -655,14 +655,16 @@ if((typeof module) !== 'undefined' && typeof nerdamer === 'undefined') {
symbol = _.multiply(polydiff(symbol.clone()), derive(b));
}
else if( g === CP || g === PL ) {
var c = _.parse(symbol);
var result = new Symbol(0);
for(var x in symbol.symbols) {
result = _.add(result, __.diff(symbol.symbols[x].clone(), d));
}
symbol = _.multiply(polydiff(symbol.clone()), result);
symbol = _.multiply(polydiff(c), result);
}

symbol.updateHash();

return symbol;
};

Expand Down Expand Up @@ -2586,4 +2588,4 @@ if((typeof module) !== 'undefined' && typeof nerdamer === 'undefined') {
//link registered functions externally
nerdamer.api();

})();
})();
2 changes: 1 addition & 1 deletion Extra.js
Expand Up @@ -588,4 +588,4 @@ if ((typeof module) !== 'undefined') {

//link registered functions externally
nerdamer.api();
}());
}());
37 changes: 30 additions & 7 deletions Solve.js
Expand Up @@ -66,6 +66,8 @@ if ((typeof module) !== 'undefined') {
core.Settings.FILTER_SOLUTIONS = true;
//the maximum number of recursive calls
core.Settings.MAX_SOLVE_DEPTH = 10;
// The tolerance that's considered close enough to zero
core.Settings.ZERO_EPSILON = 1e-9;

core.Symbol.prototype.hasTrig = function () {
return this.containsFunction(['cos', 'sin', 'tan', 'cot', 'csc', 'sec']);
Expand Down Expand Up @@ -215,8 +217,7 @@ if ((typeof module) !== 'undefined') {
else {
symbol = this.symbol;
}



return solve(symbol, x).map(function (x) {
return new core.Expression(x);
});
Expand Down Expand Up @@ -1066,7 +1067,10 @@ if ((typeof module) !== 'undefined') {
cfact;

var correct_denom = function (symbol) {
symbol = _.expand(symbol);
symbol = _.expand(symbol, {
expand_denominator: true,
expand_functions: true
});
var original = symbol.clone(); //preserve the original

if (symbol.symbols) {
Expand Down Expand Up @@ -1180,7 +1184,7 @@ if ((typeof module) !== 'undefined') {

//try for nested sqrts as per issue #486
add_to_result(__.sqrtSolve(eq, solve_for));

//polynomial single variable
if (numvars === 1) {
if (eq.isPoly(true)) {
Expand Down Expand Up @@ -1286,7 +1290,6 @@ if ((typeof module) !== 'undefined') {
console.log(e);
}
}

}
else {
//The idea here is to go through the equation and collect the coefficients
Expand Down Expand Up @@ -1418,13 +1421,33 @@ if ((typeof module) !== 'undefined') {
}
}
}

if (cfact) {
solutions = solutions.map(function (x) {
return _.pow(x, new Symbol(cfact));
});
}

// Perform some cleanup but don't do it agains arrays, etc
// Check it actually evaluates to zero
if(isSymbol(eqns)) {
var knowns = {};
solutions = solutions.filter(function(x) {
try {
knowns[solve_for] = x;
var zero = Number(evaluate(eqns, knowns));
// Allow symbolic answers
if(isNaN(zero)) {
return true;
}
return Math.abs(zero) <= core.Settings.ZERO_EPSILON;
}
catch(e) {
return false;
}
});
}

return solutions;
};

Expand Down Expand Up @@ -1471,4 +1494,4 @@ if ((typeof module) !== 'undefined') {
}
]);
nerdamer.api();
})();
})();
3 changes: 2 additions & 1 deletion index.html
Expand Up @@ -113,7 +113,7 @@
border: 2px solid #ABABAB;
border-radius: 3px;
padding: 5px;
color: #707070;
color: #707070;
font-size: 18px;
width: 80%;
margin-bottom: 4px;
Expand All @@ -131,6 +131,7 @@
color: #707070;
border-radius: 3px;
margin-left: 2px;
}
</style>
</head>
<body>
Expand Down

0 comments on commit c846f3f

Please sign in to comment.