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 #517 from jiggzson/dev
Browse files Browse the repository at this point in the history
v. 1.1.2
  • Loading branch information
jiggzson authored Jan 8, 2020
2 parents 536c583 + 3cddc37 commit 06f5535
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
22 changes: 19 additions & 3 deletions Calculus.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ if((typeof module) !== 'undefined' && typeof nerdamer === 'undefined') {
}

if(symbol.group === FN && !isSymbol(symbol.power)) {
var a = derive(symbol);
var a = derive(_.parse(symbol));
var b = __.diff(symbol.args[0].clone(), d);
symbol = _.multiply(a, b);//chain rule
}
Expand Down Expand Up @@ -1190,14 +1190,26 @@ if((typeof module) !== 'undefined' && typeof nerdamer === 'undefined') {
var p = symbol.power.toString();
if(isInt(p))
depth = depth - p; //it needs more room to find the integral
retval = __.integration.by_parts(symbol, dx, depth, opt);

if(!arg.isComposite())
retval = _.multiply(_.parse(m),__.integration.by_parts(symbol, dx, depth, opt));
else {
//integral u du
var u = core.Utils.getU(symbol);
var f = _.pow(_.parse(LOG+inBrackets(u)),new Symbol(p));
var du = __.diff(arg, dx);
var u_du = _.multiply(f, du);
var integral = __.integrate(u_du, u, depth, opt);
retval = _.multiply(_.parse(m),integral.sub(u, arg));
}

}
else if(fname === TAN && symbol.power.lessThan(0)) {
//convert to cotangent
var sym = symbol.clone();
sym.power.negate();
sym.fname = COT;
return __.integrate(sym, dx, depth);
return _.multiply(_.parse(m),__.integrate(sym, dx, depth));
}
else {
if(!a.contains(dx, true) && symbol.isLinear()) { //perform a deep search for safety
Expand Down Expand Up @@ -1387,6 +1399,10 @@ if((typeof module) !== 'undefined' && typeof nerdamer === 'undefined') {
retval = __.integration.partial_fraction(symbol, dx, depth);
}
else if(g === CB) {
var den = symbol.getDenom();
if(den.group === S)
symbol = _.expand(symbol);

//separate the coefficient since all we care about are symbols containing dx
var coeff = symbol.stripVar(dx);
//now get only those that apply
Expand Down
4 changes: 2 additions & 2 deletions Solve.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ if ((typeof module) !== 'undefined') {
//start with the symbol and remove each variable and its coefficient
var num = e.clone();
vars.map(function(e) {
num = num.stripVar(e);
num = num.stripVar(e, true);
});
c.set(i, 0, num.negate());
}
Expand Down Expand Up @@ -1427,4 +1427,4 @@ if ((typeof module) !== 'undefined') {
}
]);
nerdamer.api();
})();
})();
9 changes: 5 additions & 4 deletions nerdamer.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var nerdamer = (function (imports) {
"use strict";

//version ======================================================================
var version = '1.1.1';
var version = '1.1.2';

//inits ========================================================================
var _ = new Parser(); //nerdamer's parser
Expand Down Expand Up @@ -3351,10 +3351,10 @@ var nerdamer = (function (imports) {
*/
},
//removes the requested variable from the symbol and returns the remainder
stripVar: function (x) {
stripVar: function (x, exclude_x) {
var retval;
if ((this.group === PL || this.group === S) && this.value === x)
retval = new Symbol(this.multiplier);
retval = new Symbol(exclude_x ? 0 : this.multiplier);
else if (this.group === CB && this.isLinear()) {
retval = new Symbol(1);
this.each(function (s) {
Expand Down Expand Up @@ -5092,8 +5092,9 @@ var nerdamer = (function (imports) {
sech: function (symbol) {
var retval;
if (Settings.PARSE2NUMBER) {
if (symbol.isConstant())
if (symbol.isConstant()) {
return new Symbol(Math.sech(symbol.valueOf()));
}
if (symbol.isImaginary()) {
return complex.evaluate(symbol, 'sech');
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description": "javascript light-weight symbolic math expression evaluator",
"name": "nerdamer",
"license": "MIT",
"version": "1.1.1",
"version": "1.1.2",
"homepage": "http://nerdamer.com/",
"directory": {
"lib": "./"
Expand Down
4 changes: 2 additions & 2 deletions spec/calculus.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ describe('calculus', function () {
},
{
given: 'integrate(log(a*x+b),x)',
expected: '-(-a^(-2)*b*log(a*x+b)+a^(-1)*x)*a+log(a*x+b)*x'
expected: '((a*x+b)*log(a*x+b)-a*x-b)*a'
},
{
given: 'integrate(x*log(x),x)',
Expand Down Expand Up @@ -600,7 +600,7 @@ describe('calculus', function () {
},
{
given: 'integrate(sin(x)^3/x,x)',
expected: '(1/4)*(-Si(3*x)+3*Si(x))'
expected: '(-1/4)*Si(3*x)+(3/4)*Si(x)'
},
{
given: 'integrate(tan(x)/sec(x)*sin(x)/tan(x),x)',
Expand Down

0 comments on commit 06f5535

Please sign in to comment.