pimath 0.0.28 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dev/index.html CHANGED
@@ -37,11 +37,10 @@
37
37
 
38
38
  <script>
39
39
  // let ne = new Pi.NumExp('5/x*sin(x*x)')
40
- let ne = new Pi.NumExp('x+3')
40
+ let ne = new Pi.NumExp('5/x*sqrt(x^2)')
41
41
 
42
- console.log(5.000000000000004)
43
- console.log(ne.evaluate({x: 5.000000000000004}))
44
- console.log(ne.evaluate({x: 5.000000000000}))
42
+ console.log(ne.rpn)
43
+ console.log(ne.evaluate({x: 0}))
45
44
 
46
45
  function dev () {
47
46
  let output = []
package/dev/pi.js CHANGED
@@ -3516,6 +3516,9 @@ class Line {
3516
3516
  isSameAs = (line) => {
3517
3517
  return this.slope.isEqual(line.slope) && this.height.isEqual(line.height);
3518
3518
  };
3519
+ isVertical = () => {
3520
+ return this.slope.isInfinity();
3521
+ };
3519
3522
  simplify = () => {
3520
3523
  let lcm = numeric_1.Numeric.lcm(this._a.denominator, this._b.denominator, this._c.denominator), gcd = numeric_1.Numeric.gcd(this._a.numerator, this._b.numerator, this._c.numerator);
3521
3524
  this.parseByCoefficient(this._a.clone().multiply(lcm).divide(gcd), this._b.clone().multiply(lcm).divide(gcd), this._c.clone().multiply(lcm).divide(gcd));
@@ -4066,12 +4069,17 @@ class Vector {
4066
4069
  this._y = values[1].y.clone().subtract(values[0].y);
4067
4070
  return this;
4068
4071
  }
4069
- if (values[0].isFraction || !isNaN(values[0])) {
4072
+ if (values[0] instanceof fraction_1.Fraction || !isNaN(values[0])) {
4070
4073
  this._x = new fraction_1.Fraction(values[0]);
4071
4074
  }
4072
- if (values[1].isFraction || !isNaN(values[1])) {
4075
+ if (values[1] instanceof fraction_1.Fraction || !isNaN(values[1])) {
4073
4076
  this._y = new fraction_1.Fraction(values[1]);
4074
4077
  }
4078
+ if ((typeof values[0] === 'object' && !isNaN(values[0].x) && !isNaN(values[0].x)) &&
4079
+ (typeof values[1] === 'object' && !isNaN(values[1].x) && !isNaN(values[1].x))) {
4080
+ this._x = new fraction_1.Fraction(+values[1].x - values[0].x);
4081
+ this._y = new fraction_1.Fraction(+values[1].y - values[0].y);
4082
+ }
4075
4083
  }
4076
4084
  return this;
4077
4085
  };
@@ -4345,6 +4353,9 @@ class NumExp {
4345
4353
  else if (element.token === 'tan') {
4346
4354
  this._addToStack(stack, Math.tan(a));
4347
4355
  }
4356
+ else if (element.token === 'sqrt') {
4357
+ this._addToStack(stack, Math.sqrt(a));
4358
+ }
4348
4359
  }
4349
4360
  }
4350
4361
  if (stack.length === 1) {
@@ -4762,7 +4773,9 @@ class Shutingyard {
4762
4773
  'sin': { precedence: 4, associative: 'right', type: ShutingyardType.FUNCTION },
4763
4774
  'cos': { precedence: 4, associative: 'right', type: ShutingyardType.FUNCTION },
4764
4775
  'tan': { precedence: 4, associative: 'right', type: ShutingyardType.FUNCTION },
4776
+ 'sqrt': { precedence: 4, associative: 'right', type: ShutingyardType.FUNCTION },
4765
4777
  };
4778
+ this._uniformize = false;
4766
4779
  }
4767
4780
  else {
4768
4781
  this._tokenConfig = {
@@ -4781,7 +4794,7 @@ class Shutingyard {
4781
4794
  this._tokenKeys = Object.keys(this._tokenConfig).sort((a, b) => b.length - a.length);
4782
4795
  return this._tokenConfig;
4783
4796
  }
4784
- NextToken2(expr, start) {
4797
+ NextToken(expr, start) {
4785
4798
  let token, tokenType;
4786
4799
  token = '';
4787
4800
  tokenType = '';
@@ -4862,7 +4875,7 @@ class Shutingyard {
4862
4875
  console.log('SECURITY LEVEL 1 EXIT');
4863
4876
  break;
4864
4877
  }
4865
- [token, tokenPos, tokenType] = this.NextToken2(expr, tokenPos);
4878
+ [token, tokenPos, tokenType] = this.NextToken(expr, tokenPos);
4866
4879
  switch (tokenType) {
4867
4880
  case 'monom':
4868
4881
  case 'coefficient':