pimath 0.0.120 → 0.0.121

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.
Files changed (171) hide show
  1. package/.eslintrc.js +23 -23
  2. package/.idea/PI.iml +7 -1
  3. package/dev/pimath.js +7929 -0
  4. package/dev/pimath.js.map +1 -0
  5. package/dist/{pi.js → pimath.js} +7612 -7840
  6. package/dist/pimath.js.map +1 -0
  7. package/dist/pimath.min.js +2 -0
  8. package/dist/pimath.min.js.map +1 -0
  9. package/docs/assets/main.js +3 -3
  10. package/docs/assets/search.js +1 -1
  11. package/docs/assets/style.css +450 -363
  12. package/docs/classes/Logicalset.Logicalset.html +119 -110
  13. package/docs/classes/Polynom.Rational.html +230 -227
  14. package/docs/classes/Vector-1.Vector.html +319 -273
  15. package/docs/classes/Vector.Point.html +189 -190
  16. package/docs/classes/algebra_equation.Equation.html +489 -446
  17. package/docs/classes/algebra_linearSystem.LinearSystem.html +228 -217
  18. package/docs/classes/algebra_monom.Monom.html +564 -507
  19. package/docs/classes/algebra_polynom.Polynom.html +774 -753
  20. package/docs/classes/coefficients_fraction.Fraction.html +573 -565
  21. package/docs/classes/geometry_circle.Circle.html +299 -299
  22. package/docs/classes/geometry_line.Line.html +511 -451
  23. package/docs/classes/geometry_triangle.Triangle.html +273 -264
  24. package/docs/classes/numeric.Numeric.html +138 -132
  25. package/docs/classes/shutingyard.Shutingyard.html +144 -133
  26. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +47 -46
  27. package/docs/enums/geometry_line.LinePropriety.html +58 -58
  28. package/docs/enums/shutingyard.ShutingyardMode.html +62 -58
  29. package/docs/enums/shutingyard.ShutingyardType.html +74 -70
  30. package/docs/index.html +31 -33
  31. package/docs/interfaces/algebra_equation.ISolution.html +61 -59
  32. package/docs/interfaces/algebra_polynom.IEuclidian.html +47 -46
  33. package/docs/interfaces/geometry_triangle.remarquableLines.html +74 -74
  34. package/docs/modules/Logicalset.html +33 -38
  35. package/docs/modules/Polynom.html +33 -38
  36. package/docs/modules/Vector-1.html +33 -38
  37. package/docs/modules/Vector.html +33 -38
  38. package/docs/modules/algebra_equation.html +35 -41
  39. package/docs/modules/algebra_linearSystem.html +31 -37
  40. package/docs/modules/algebra_monom.html +33 -39
  41. package/docs/modules/algebra_polynom.html +35 -41
  42. package/docs/modules/coefficients_fraction.html +33 -39
  43. package/docs/modules/geometry_circle.html +31 -37
  44. package/docs/modules/geometry_line.html +33 -39
  45. package/docs/modules/geometry_triangle.html +33 -39
  46. package/docs/modules/numeric.html +31 -37
  47. package/docs/modules/shutingyard.html +41 -47
  48. package/docs/types/algebra_monom.literalType.html +33 -37
  49. package/docs/types/algebra_polynom.PolynomParsingType.html +33 -37
  50. package/docs/types/coefficients_fraction.FractionParsingType.html +32 -36
  51. package/docs/types/shutingyard.Token.html +38 -42
  52. package/docs/types/shutingyard.tokenType.html +40 -44
  53. package/docs/variables/shutingyard.tokenConstant.html +37 -41
  54. package/esm/index.d.ts +38 -41
  55. package/esm/index.js +43 -46
  56. package/esm/index.js.map +1 -1
  57. package/esm/maths/algebra/equation.d.ts +119 -117
  58. package/esm/maths/algebra/equation.js +796 -785
  59. package/esm/maths/algebra/equation.js.map +1 -1
  60. package/esm/maths/algebra/linearSystem.d.ts +39 -38
  61. package/esm/maths/algebra/linearSystem.js +278 -262
  62. package/esm/maths/algebra/linearSystem.js.map +1 -1
  63. package/esm/maths/algebra/logicalset.d.ts +28 -28
  64. package/esm/maths/algebra/logicalset.js +157 -157
  65. package/esm/maths/algebra/monom.d.ts +206 -206
  66. package/esm/maths/algebra/monom.js +908 -908
  67. package/esm/maths/algebra/monom.js.map +1 -1
  68. package/esm/maths/algebra/polynom.d.ts +157 -157
  69. package/esm/maths/algebra/polynom.js +1277 -1277
  70. package/esm/maths/algebra/rational.d.ts +45 -45
  71. package/esm/maths/algebra/rational.js +183 -183
  72. package/esm/maths/algebra/study/rationalStudy.d.ts +28 -28
  73. package/esm/maths/algebra/study/rationalStudy.js +243 -243
  74. package/esm/maths/algebra/study.d.ts +142 -142
  75. package/esm/maths/algebra/study.js +377 -377
  76. package/esm/maths/algebra/study.js.map +1 -1
  77. package/esm/maths/coefficients/fraction.d.ts +90 -90
  78. package/esm/maths/coefficients/fraction.js +516 -516
  79. package/esm/maths/coefficients/fraction.js.map +1 -1
  80. package/esm/maths/coefficients/nthRoot.d.ts +23 -23
  81. package/esm/maths/coefficients/nthRoot.js +136 -136
  82. package/esm/maths/geometry/circle.d.ts +45 -45
  83. package/esm/maths/geometry/circle.js +323 -323
  84. package/esm/maths/geometry/line.d.ts +99 -99
  85. package/esm/maths/geometry/line.js +481 -481
  86. package/esm/maths/geometry/line.js.map +1 -1
  87. package/esm/maths/geometry/point.d.ts +34 -34
  88. package/esm/maths/geometry/point.js +166 -166
  89. package/esm/maths/geometry/point.js.map +1 -1
  90. package/esm/maths/geometry/triangle.d.ts +85 -85
  91. package/esm/maths/geometry/triangle.js +268 -268
  92. package/esm/maths/geometry/vector.d.ts +41 -41
  93. package/esm/maths/geometry/vector.js +197 -197
  94. package/esm/maths/geometry/vector.js.map +1 -1
  95. package/esm/maths/numeric.d.ts +28 -28
  96. package/esm/maths/numeric.js +180 -180
  97. package/esm/maths/numexp.d.ts +19 -0
  98. package/esm/maths/numexp.js +186 -0
  99. package/esm/maths/numexp.js.map +1 -0
  100. package/esm/maths/randomization/random.d.ts +23 -23
  101. package/esm/maths/randomization/random.js +78 -78
  102. package/esm/maths/randomization/random.js.map +1 -1
  103. package/esm/maths/randomization/randomCore.d.ts +7 -7
  104. package/esm/maths/randomization/randomCore.js +21 -21
  105. package/esm/maths/randomization/rndFraction.d.ts +12 -12
  106. package/esm/maths/randomization/rndFraction.js +43 -43
  107. package/esm/maths/randomization/rndGeometryLine.d.ts +12 -12
  108. package/esm/maths/randomization/rndGeometryLine.js +45 -45
  109. package/esm/maths/randomization/rndGeometryPoint.d.ts +12 -12
  110. package/esm/maths/randomization/rndGeometryPoint.js +60 -60
  111. package/esm/maths/randomization/rndHelpers.d.ts +23 -23
  112. package/esm/maths/randomization/rndHelpers.js +76 -76
  113. package/esm/maths/randomization/rndMonom.d.ts +12 -12
  114. package/esm/maths/randomization/rndMonom.js +52 -52
  115. package/esm/maths/randomization/rndPolynom.d.ts +13 -13
  116. package/esm/maths/randomization/rndPolynom.js +74 -74
  117. package/esm/maths/randomization/rndTypes.d.ts +34 -34
  118. package/esm/maths/randomization/rndTypes.js +2 -2
  119. package/esm/maths/shutingyard.d.ts +59 -59
  120. package/esm/maths/shutingyard.js +442 -442
  121. package/esm/maths/shutingyard.js.map +1 -1
  122. package/package.json +11 -11
  123. package/public/index.html +50 -81
  124. package/public/playground.html +7 -8
  125. package/src/index.ts +2 -5
  126. package/src/maths/algebra/equation.ts +16 -0
  127. package/src/maths/algebra/linearSystem.ts +20 -0
  128. package/src/maths/algebra/study.ts +1 -1
  129. package/src/maths/{expressions/numexp.ts → numexp.ts} +2 -2
  130. package/tests/algebra/equation.test.ts +19 -5
  131. package/tests/algebra/linear.test.ts +3 -11
  132. package/tests/algebra/polynom.test.ts +7 -8
  133. package/tests/algebra/rationnal.test.ts +1 -1
  134. package/tests/algebra/study.test.ts +2 -9
  135. package/tests/coefficients/fraction.test.ts +8 -8
  136. package/tests/custom.test.ts +33 -37
  137. package/tests/numeric.test.ts +1 -2
  138. package/tests/numexp.test.ts +1 -5
  139. package/tests/shutingyard.test.ts +3 -3
  140. package/webpack-production-min.config.js +1 -1
  141. package/webpack-production.config.js +1 -1
  142. package/webpack.config.js +1 -1
  143. package/dist/pi.js.map +0 -1
  144. package/dist/pi.min.js +0 -2
  145. package/dist/pi.min.js.map +0 -1
  146. package/docs/classes/expressions_numexp.NumExp.html +0 -236
  147. package/docs/classes/expressions_polynomexp.PolynomExpFactor.html +0 -317
  148. package/docs/classes/expressions_polynomexp.PolynomExpProduct.html +0 -285
  149. package/docs/modules/expressions_numexp.html +0 -71
  150. package/docs/modules/expressions_polynomexp.html +0 -73
  151. package/docs/modules.html +0 -76
  152. package/graph.svg +0 -1033
  153. package/src/maths/expressions/ExpressionTree.ts +0 -172
  154. package/src/maths/expressions/expression.ts +0 -286
  155. package/src/maths/expressions/expressionFactor.ts +0 -190
  156. package/src/maths/expressions/expressionMember.ts +0 -233
  157. package/src/maths/expressions/expressionOperators.ts +0 -49
  158. package/src/maths/expressions/expressionParser.ts +0 -295
  159. package/src/maths/expressions/factors/ExpFactor.ts +0 -39
  160. package/src/maths/expressions/factors/ExpFactorConstant.ts +0 -60
  161. package/src/maths/expressions/factors/ExpFactorExponential.ts +0 -26
  162. package/src/maths/expressions/factors/ExpFactorNumber.ts +0 -72
  163. package/src/maths/expressions/factors/ExpFactorPower.ts +0 -42
  164. package/src/maths/expressions/factors/ExpFactorTrigo.ts +0 -53
  165. package/src/maths/expressions/factors/ExpFactorVariable.ts +0 -45
  166. package/src/maths/expressions/internals.ts +0 -14
  167. package/src/maths/expressions/polynomexp.bkp.ts +0 -221
  168. package/src/maths/expressions/polynomexp.ts +0 -310
  169. package/tests/expressions/expressions.test.ts +0 -145
  170. package/tests/expressions/expressiontree.test.ts +0 -11
  171. package/tests/polynomexp.test.ts +0 -12
@@ -1,310 +0,0 @@
1
- import {Polynom, PolynomParsingType} from "../algebra/polynom";
2
- import {Fraction, FractionParsingType} from "../coefficients/fraction";
3
-
4
- type PolynomExpMathFunctionType = { name: string; fn: Function, tex: string }
5
-
6
- export class PolynomExpFactor {
7
- constructor(polynom: PolynomParsingType, degree?: FractionParsingType, mathFunction?: PolynomExpMathFunctionType) {
8
- this._polynom = new Polynom(polynom)
9
- this._degree = new Fraction(degree === undefined ? 1 : degree)
10
- this._fn = mathFunction
11
- this._powerAsInteger = true
12
- this._forceParenthesis = true
13
-
14
- }
15
-
16
- private _forceParenthesis: boolean
17
-
18
- get forceParenthesis(): boolean {
19
- return this._forceParenthesis;
20
- }
21
-
22
- set forceParenthesis(value: boolean) {
23
- this._forceParenthesis = value;
24
- }
25
-
26
- private _fn: PolynomExpMathFunctionType
27
-
28
- get fn(): PolynomExpMathFunctionType {
29
- return this._fn;
30
- }
31
-
32
- set fn(value: PolynomExpMathFunctionType) {
33
- this._fn = value;
34
- }
35
-
36
- private _powerAsInteger: boolean
37
-
38
- get powerAsInteger(): boolean {
39
- return this._powerAsInteger;
40
- }
41
-
42
- set powerAsInteger(value: boolean) {
43
- this._powerAsInteger = value;
44
- }
45
-
46
- private _polynom: Polynom
47
-
48
- get polynom(): Polynom {
49
- return this._polynom;
50
- }
51
-
52
- set polynom(value: Polynom) {
53
- this._polynom = value;
54
- }
55
-
56
- private _degree: Fraction
57
-
58
- get degree(): Fraction {
59
- return this._degree;
60
- }
61
-
62
- set degree(value: Fraction) {
63
- this._degree = value;
64
- }
65
-
66
- get tex(): string {
67
- let tex
68
-
69
- if (this._degree.isOne() && (this._fn !== undefined || !this._forceParenthesis)) {
70
- // If degree is one, no need to add the parenthesis.
71
- tex = this._polynom.tex
72
- } else {
73
- // the degree is not one, add the parenthesis.
74
- if (this._powerAsInteger && !this._degree.isRelative()) {
75
- // the degree is a fraction and we want natural powers => use sqrt.
76
- tex = `\\sqrt${this._degree.denominator !== 2 ? `[ ${this._degree.denominator} ]` : ''}{ ${this._polynom.tex} }^{ ${this._degree.numerator} }`
77
- } else if (this.isCoefficient && this.firstCoefficient.isNatural()) {
78
- // the value is a natural number (eg 3, 7, ...)
79
- tex = this._polynom.tex + this._texDegree
80
- } else {
81
- // In any other case, add the parenthesis by default
82
- tex = `\\left( ${this._polynom.tex} \\right)${this._texDegree}`
83
- }
84
- }
85
-
86
- if (this._fn !== undefined && this._fn.tex !== undefined) {
87
- tex = `${this._fn.tex}\\left( ${tex} \\right)`
88
- }
89
- return tex
90
- }
91
-
92
- get isCoefficient(): boolean {
93
- // TODO: Maybe reduce the coefficient if it isn't of degree one.
94
- return this._polynom.degree().isZero();
95
-
96
- }
97
-
98
- get firstCoefficient(): Fraction {
99
- return this._polynom.monomByDegree().coefficient
100
- }
101
-
102
- private get _texDegree(): string {
103
- if (this._degree.isOne()) {
104
- return ''
105
- } else {
106
- return `^{ ${this._degree.tfrac} }`
107
- }
108
- }
109
-
110
- setForceParenthesis(value?: boolean): PolynomExpFactor {
111
- this._forceParenthesis = value === undefined || value
112
- return this
113
- }
114
-
115
- derivative(letter?: string): PolynomExpProduct {
116
- if (this._degree.isOne()) {
117
- return new PolynomExpProduct(
118
- new PolynomExpFactor(this._polynom.clone().derivative(letter))
119
- )
120
- } else {
121
- return new PolynomExpProduct(
122
- new PolynomExpFactor(this._degree.clone()),
123
- new PolynomExpFactor(this._polynom.clone().derivative(letter)),
124
- new PolynomExpFactor(this._polynom.clone(), this._degree.clone().subtract(1))
125
- )
126
- }
127
- }
128
- }
129
-
130
- export class PolynomExpProduct {
131
- constructor(...values: PolynomExpFactor[]) {
132
- this._factors = values || []
133
- this._positive = true
134
- this._asPositiveDegree = true
135
- }
136
-
137
- private _fn: PolynomExpMathFunctionType
138
-
139
- get fn(): PolynomExpMathFunctionType {
140
- return this._fn;
141
- }
142
-
143
- set fn(value: PolynomExpMathFunctionType) {
144
- this._fn = value;
145
- }
146
-
147
- private _factors: PolynomExpFactor[]
148
-
149
- get factors(): PolynomExpFactor[] {
150
- return this._factors;
151
- }
152
-
153
- set factors(value: PolynomExpFactor[]) {
154
- this._factors = value;
155
- }
156
-
157
- private _positive: boolean
158
-
159
- get positive(): boolean {
160
- return this._positive;
161
- }
162
-
163
- set positive(value: boolean) {
164
- this._positive = value;
165
- }
166
-
167
- private _asPositiveDegree: boolean
168
-
169
- get asPositiveDegree(): boolean {
170
- return this._asPositiveDegree;
171
- }
172
-
173
- set asPositiveDegree(value: boolean) {
174
- this._asPositiveDegree = value;
175
- }
176
-
177
- get tex(): string {
178
- let parenthesis = this._factors.length>1
179
- // Default value
180
- let tex = this._factors.map(factor => factor.setForceParenthesis(parenthesis).tex).join(' \\cdot ')
181
-
182
- // Change the value in some cases...
183
- if (this._asPositiveDegree) {
184
- const numerators = this._factors.filter(x => x.degree.isPositive()),
185
- denominators = this._factors.filter(x => x.degree.isNegative())
186
-
187
- let numeratorsAsTex, denominatorsAsTex
188
-
189
- if (denominators.length > 0) {
190
- if (numerators.length === 0) {
191
- numeratorsAsTex = [1]
192
- } else if (numerators.length === 1) {
193
- numeratorsAsTex = [numerators[0].setForceParenthesis(false).tex]
194
- } else {
195
- parenthesis = numerators.length>1
196
- numeratorsAsTex = numerators.map(factor => factor.setForceParenthesis(parenthesis).tex)
197
- }
198
-
199
- // Change all denominators degrees to positive.
200
- denominators.map(x => x.degree.opposed())
201
- if (denominators.length === 1) {
202
- denominatorsAsTex = [denominators[0].setForceParenthesis(false).tex]
203
- } else {
204
- parenthesis = denominators.length>1
205
- denominatorsAsTex = denominators.map(factor => factor.setForceParenthesis(parenthesis).tex)
206
- }
207
- // restore all degrees to negative again.
208
- denominators.map(x => x.degree.opposed())
209
-
210
- tex = `\\frac{ ${numeratorsAsTex.join(' \\cdot ')} }{ ${denominatorsAsTex.join(' \\cdot ')} }`
211
- }
212
- }
213
-
214
- // Apply the modification
215
- if (this._fn !== undefined && this._fn.name !== undefined && this._fn.name !== '') {
216
- tex = `${this._fn.tex}\\left( ${tex} \\right)`
217
- }
218
- return tex
219
- }
220
-
221
- reduce(): PolynomExpProduct {
222
- let coefficients = this._factors.filter(factor => factor.isCoefficient),
223
- polynoms = this._factors.filter(factor => !factor.isCoefficient)
224
-
225
- let result = new Fraction().one()
226
-
227
- if (coefficients.length > 1) {
228
- for (const factor of coefficients) {
229
- if (factor.degree.isPositive()) {
230
- result.multiply(factor.polynom.monoms[0].coefficient.pow(factor.degree))
231
- } else {
232
- result.divide(factor.polynom.monoms[0].coefficient.pow(factor.degree.clone().abs()))
233
- }
234
- }
235
- } else if (coefficients.length === 1) {
236
- result = coefficients[0].polynom.monoms[0].coefficient
237
- }
238
-
239
- if (result.isOne()) {
240
- this._factors = [...polynoms]
241
- } else if (!result.isRelative()) {
242
- this._factors = [
243
- new PolynomExpFactor(result.numerator),
244
- new PolynomExpFactor(result.denominator, -1),
245
- ...polynoms
246
- ]
247
- } else {
248
- this._factors = [
249
- new PolynomExpFactor(result),
250
- ...polynoms
251
- ]
252
- }
253
- return this
254
- }
255
-
256
- integrate(letter?: string): PolynomExpProduct {
257
- // Handle this kind of case:
258
- // A * f' * F^n
259
- // A * f' / F^n, n != 1
260
- // A * f_1 * f_2 * f_3, where (f_1 * f_2)' = f_3
261
- if (this._factors.length === 2) {
262
- // Check polynoms degree: one must of one degree less than the other.
263
- let d1 = this._factors[0].polynom.degree(letter).value,
264
- d2 = this._factors[1].polynom.degree(letter).value
265
-
266
- if (d1 === d2 + 1) {
267
- return this._integrateWithInternalDerivative(this._factors[0], this._factors[1], letter)
268
- } else if (d1 + 1 === d2) {
269
- return this._integrateWithInternalDerivative(this._factors[1], this._factors[0], letter)
270
- }
271
- }
272
- return
273
- }
274
-
275
- public applyMathFunction(mathFn: PolynomExpMathFunctionType): PolynomExpProduct {
276
- this._fn = mathFn
277
- return this
278
- }
279
-
280
- private _integrateWithInternalDerivative(P: PolynomExpFactor, Pinternal: PolynomExpFactor, letter?: string): PolynomExpProduct {
281
- // Get the internal derivative
282
- let internalDerivative: Polynom = P.polynom.clone().derivative(letter)
283
-
284
- // Get the factor.
285
- let {quotient, reminder} = Pinternal.polynom.clone().euclidian(internalDerivative)
286
-
287
- if (reminder.isZero() && quotient.degree(letter).isZero()) {
288
- // All the conditions are done. Actual situation is
289
- // (4x-10)(x^2-5x+7)^9
290
- // P1 = (x^2-5x+7), P2 = (2x-5)
291
- // => 1/10 * quotient * (x^2-5x+7)^10
292
-
293
- if (P.degree.isEqual(-1)) {
294
- return (new PolynomExpProduct(
295
- new PolynomExpFactor(quotient, 1),
296
- new PolynomExpFactor(P.polynom.clone(), 1, {
297
- name: 'ln', tex: '\\ln', fn: (x: number) => Math.log(x)
298
- })
299
- ))
300
- } else {
301
- return new PolynomExpProduct(
302
- new PolynomExpFactor(P.degree.clone().add(1).invert(), 1),
303
- new PolynomExpFactor(quotient, 1),
304
- new PolynomExpFactor(P.polynom.clone(), P.degree.clone().add(1))
305
- )
306
- }
307
- }
308
- return
309
- }
310
- }
@@ -1,145 +0,0 @@
1
- import {ExpFactorVariable} from "../../src/maths/expressions/factors/ExpFactorVariable";
2
- import {expect} from "chai";
3
- import {ExpFactorNumber} from "../../src/maths/expressions/factors/ExpFactorNumber";
4
- import {Expression} from "../../src/maths/expressions/expression";
5
- import {ExpFactorTrigo} from "../../src/maths/expressions/factors/ExpFactorTrigo";
6
- import {ExpFactor} from "../../src/maths/expressions/factors/ExpFactor";
7
- import {ExpressionMember} from "../../src/maths/expressions/expressionMember";
8
- import {ExpressionParser} from "../../src/maths/expressions/expressionParser";
9
- import {expressionOperators} from "../../src/maths/expressions/expressionOperators";
10
-
11
- describe('Expressions tests', () => { // the tests container
12
- it('should make some test', () => {
13
-
14
- // let a = new ExpressionParser('3x').expression
15
- // let a = new ExpressionParser('3x+5').expression
16
- // let a = new ExpressionParser('3x^2+5').expression
17
- // let a = new ExpressionParser('3x^(2/3)+5').expression
18
- // let a = new ExpressionParser('3x(x+4)').expression
19
- // let a = new ExpressionParser('sin(cos(3picos(3pi)-5))+sqrt(e-sin(3pi/2))').expression
20
- // let a = new ExpressionParser('3-nthrt(x-3,5)').expression
21
- // console.log(a.isPolynom())
22
- // let b = new ExpressionParser('3/2x^2-5x+7').expression
23
- // console.log(b.tex, b.isPolynom())
24
- // console.log(b.members[0].member.coefficient().tex)
25
- // console.log(b.members[0].member.litteral().tex)
26
- // console.log(b.structure())
27
- //
28
-
29
- // let c = new ExpressionParser('3/2x^2+5/3x-7').expression
30
- // console.log(c.tex)
31
- // console.log(c.display)
32
-
33
- // let d = new ExpressionParser('sqrt(16)*sqrt(15^4)+9/15').expression
34
- let d = new ExpressionParser('nthrt(16,4)').expression
35
- console.log(d.tex)
36
- console.log(d.members[0].member.reduce().tex)
37
- console.log(d.structure())
38
- // console.log(d.display)
39
-
40
- // console.log(d.structure())
41
- // console.log(c.display)
42
- // console.log(c.members[0].member.literal().factors.length)
43
- // console.log(c.members[0].member.reduce().tex);
44
- // console.log(c.members[1].member.reduce().tex);
45
- })
46
-
47
- it('should make some operations', ()=>{
48
- let a = new ExpressionParser('3x').expression,
49
- b = new ExpressionParser('5x^2').expression,
50
- c = new ExpressionParser('9x-2').expression
51
-
52
- console.log(a.tex)
53
- console.log(b.tex)
54
- console.log(c.tex)
55
-
56
- let sum = expressionOperators.add(a, b, c)
57
- console.log(sum.tex)
58
-
59
- let diff = expressionOperators.subtract(a, b)
60
- console.log(diff.tex)
61
-
62
- let mult = expressionOperators.multiply(a, b, c)
63
- console.log(mult.tex)
64
-
65
- let div = expressionOperators.divide(a, c)
66
- console.log(div.tex)
67
- })
68
- it('should work :)', () => {
69
-
70
- const expVar = new ExpFactorVariable('y', 3, 5)
71
- expect(expVar.tex).to.be.equal('\\sqrt[5]{ y }^{ 3 }')
72
-
73
- const expNum = new ExpFactorNumber(17, 3, 5)
74
- expect(expNum.tex).to.be.equal('\\sqrt[5]{ 17 }^{ 3 }')
75
-
76
- const expProduct1 = new ExpressionMember(expNum, expVar)
77
- const expProduct2 = new ExpressionMember(
78
- new ExpFactorNumber(4),
79
- new ExpFactorVariable('t', 7, 2)
80
- )
81
- expect(expProduct2.tex).to.be.equal("4\\sqrt{ t }^{ 7 }")
82
-
83
- const expr = new Expression(
84
- expProduct1,
85
- expProduct2
86
- )
87
-
88
- const ExpSin = new ExpFactorTrigo(
89
- 'sin',
90
- expr,
91
- 3, 7
92
- )
93
-
94
- const expNum1 = new Expression(
95
- new ExpressionMember(
96
- new ExpFactorNumber(3, 2, 7),
97
- new ExpFactorNumber(4, -3, 2)
98
- ),
99
- new ExpressionMember(
100
- new ExpFactorNumber(5),
101
- new ExpFactor(
102
- new Expression(
103
- new ExpressionMember(
104
- new ExpFactorNumber(3, 2),
105
- new ExpFactorNumber(2, 1, 3)
106
- ),
107
- new ExpressionMember(
108
- new ExpFactorNumber(-4, 3),
109
- new ExpFactorNumber(7, 2, 6)
110
- ),
111
- new ExpressionMember(
112
- new ExpFactorNumber(-3),
113
- ExpSin
114
- )
115
- ), 2, 3
116
- )
117
- )
118
- )
119
-
120
- expect(expNum1.hasVariable()).to.be.false;
121
- const expNumSin = new Expression(
122
- new ExpressionMember(
123
- new ExpFactorTrigo('sin', expNum1)
124
- )
125
- )
126
-
127
- expect(expNumSin.isNumeric()).to.be.true;
128
-
129
- })
130
-
131
- it('should parse an expression', () => {
132
-
133
- // let E = new Expression().parse('3x')
134
- // console.log(E.tex)
135
- //
136
- // const SY5: Shutingyard = new Shutingyard().parse('3/2*x^(-3)-5*x*y-12');
137
- //
138
- // console.log(SY5.rpn.map(x=>x.token))
139
- // console.log(SY5.rpn)
140
- //
141
- // const expr = new Expression()
142
- // expr.parse('3/2*x^(-3)-5*x*y-12')
143
- })
144
-
145
- });
@@ -1,11 +0,0 @@
1
- import {ExpressionTree} from "../../src/maths/expressions/ExpressionTree";
2
-
3
- describe('Expressions test', () => { // the tests container
4
- it('Parsing tree', () => {
5
- // let ET = new ExpressionTree('3(x-4)^2')
6
- let ET = new ExpressionTree('3(x-7)^2-5sqrt(5x-3)')
7
-
8
- console.log(ET.tex)
9
- })
10
-
11
- });
@@ -1,12 +0,0 @@
1
- import {describe} from "mocha";
2
- import {PolynomExpFactor, PolynomExpProduct} from "../src/maths/expressions/polynomexp";
3
-
4
- describe('PolynomExpression concepts', () => {
5
- it('should display tex', function () {
6
- const F1 = new PolynomExpFactor('2x-5', 2.5),
7
- F2 = new PolynomExpFactor('2-x', 0.5),
8
- PP = new PolynomExpProduct(F1, F2)
9
-
10
- const D = F1.derivative()
11
- });
12
- })