pimath 0.2.7 → 0.2.9
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/dist/pimath.js +5581 -5025
- package/dist/pimath.js.map +1 -1
- package/package.json +16 -16
- package/src/algebra/equation.ts +21 -22
- package/src/algebra/factor.ts +11 -0
- package/src/algebra/polyFactor.ts +37 -5
- package/src/algebra/polynom.ts +19 -16
- package/types/algebra/equation.d.ts +6 -58
- package/types/algebra/equation.d.ts.map +1 -1
- package/types/algebra/equationSolver.d.ts +4 -3
- package/types/algebra/factor.d.ts +4 -3
- package/types/algebra/factor.d.ts.map +1 -1
- package/types/algebra/index.d.ts +1 -0
- package/types/algebra/linearSystem.d.ts +6 -5
- package/types/algebra/logicalset.d.ts +1 -7
- package/types/algebra/matrix.d.ts +4 -3
- package/types/algebra/monom.d.ts +3 -115
- package/types/algebra/operations.d.ts +2 -1
- package/types/algebra/polyFactor.d.ts +6 -14
- package/types/algebra/polyFactor.d.ts.map +1 -1
- package/types/algebra/polynom.d.ts +6 -36
- package/types/algebra/polynom.d.ts.map +1 -1
- package/types/analyze/index.d.ts +3 -2
- package/types/analyze/solution.d.ts +4 -3
- package/types/analyze/tableOfSigns.d.ts +4 -3
- package/types/coefficients/fraction.d.ts +2 -14
- package/types/coefficients/index.d.ts +1 -0
- package/types/coefficients/root.d.ts +3 -5
- package/types/geometry/TupleN.d.ts +3 -2
- package/types/geometry/circle.d.ts +6 -15
- package/types/geometry/geomMath.d.ts +4 -3
- package/types/geometry/index.d.ts +1 -0
- package/types/geometry/line.d.ts +7 -16
- package/types/geometry/line3.d.ts +5 -9
- package/types/geometry/plane3.d.ts +6 -5
- package/types/geometry/point.d.ts +6 -5
- package/types/geometry/sphere3.d.ts +5 -4
- package/types/geometry/triangle.d.ts +6 -12
- package/types/geometry/vector.d.ts +5 -4
- package/types/helpers.d.ts +1 -0
- package/types/index.d.ts +22 -21
- package/types/numeric.d.ts +1 -16
- package/types/pimath.interface.d.ts +5 -4
- package/types/randomization/algebra/rndEquation.d.ts +3 -2
- package/types/randomization/algebra/rndMonom.d.ts +3 -2
- package/types/randomization/algebra/rndPolynom.d.ts +3 -2
- package/types/randomization/coefficient/rndFraction.d.ts +3 -2
- package/types/randomization/geometry/rndCircle.d.ts +3 -2
- package/types/randomization/geometry/rndLine.d.ts +3 -2
- package/types/randomization/geometry/rndLine3.d.ts +3 -2
- package/types/randomization/geometry/rndVector.d.ts +3 -2
- package/types/randomization/random.d.ts +11 -10
- package/types/randomization/rndHelpers.d.ts +1 -14
- package/types/randomization/rndTypes.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pimath",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "A math library for teacher :)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/pimath.js",
|
|
@@ -38,22 +38,22 @@
|
|
|
38
38
|
"url": "git+https://github.com/basilgass/PiMath.git"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@tailwindcss/vite": "^4.
|
|
42
|
-
"@
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
41
|
+
"@tailwindcss/vite": "^4.3.2",
|
|
42
|
+
"@types/eslint": "^9.6.1",
|
|
43
|
+
"@vitejs/plugin-vue": "^6.0.7",
|
|
44
|
+
"autoprefixer": "^10.5.2",
|
|
45
|
+
"dependency-cruiser": "^18.0.0",
|
|
46
|
+
"eslint": "^10.6.0",
|
|
47
|
+
"globals": "^17.7.0",
|
|
48
|
+
"tailwindcss": "^4.3.2",
|
|
49
|
+
"ts-loader": "^9.6.2",
|
|
49
50
|
"ts-node": "^10.9.2",
|
|
50
|
-
"typedoc": "^0.28.
|
|
51
|
-
"typescript": "^
|
|
52
|
-
"typescript-eslint": "^8.
|
|
53
|
-
"vite": "^
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"vue-router": "^5.0.2"
|
|
51
|
+
"typedoc": "^0.28.20",
|
|
52
|
+
"typescript": "^6.0.3",
|
|
53
|
+
"typescript-eslint": "^8.63.0",
|
|
54
|
+
"vite": "^8.1.4",
|
|
55
|
+
"vitest": "^4.1.10",
|
|
56
|
+
"vue-router": "^5.1.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"piexpression": "^0.1.3"
|
package/src/algebra/equation.ts
CHANGED
|
@@ -7,15 +7,14 @@ import type {
|
|
|
7
7
|
IPiMathObject,
|
|
8
8
|
literalType
|
|
9
9
|
} from "../pimath.interface"
|
|
10
|
-
import {Fraction} from "../coefficients
|
|
10
|
+
import {Fraction} from "../coefficients"
|
|
11
11
|
import {Numeric} from "../numeric"
|
|
12
12
|
import {EquationSolver} from "./equationSolver"
|
|
13
13
|
import {Monom} from "./monom"
|
|
14
14
|
import {Polynom} from "./polynom"
|
|
15
|
-
import type {Solution} from "../analyze
|
|
15
|
+
import type {Solution} from "../analyze"
|
|
16
16
|
|
|
17
|
-
export class Equation implements
|
|
18
|
-
IPiMathObject<Equation>,
|
|
17
|
+
export class Equation implements IPiMathObject<Equation>,
|
|
19
18
|
IEquation<Equation>,
|
|
20
19
|
IAlgebra<Equation> {
|
|
21
20
|
|
|
@@ -96,15 +95,15 @@ export class Equation implements
|
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
public static makeSolutionsUnique(solutions: Solution[], sorted?: boolean): Solution[] {
|
|
99
|
-
const solutionAsTex: string[] = []
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
const solutionAsTex: string[] = []
|
|
99
|
+
const uniqueSolutions = solutions.filter(sol => {
|
|
100
|
+
if (!solutionAsTex.includes(sol.tex)) {
|
|
101
|
+
solutionAsTex.push(sol.tex)
|
|
102
|
+
return true
|
|
103
|
+
} else {
|
|
104
|
+
return false
|
|
105
|
+
}
|
|
106
|
+
})
|
|
108
107
|
|
|
109
108
|
if (sorted === true) {
|
|
110
109
|
uniqueSolutions.sort((a, b) => a.value - b.value)
|
|
@@ -191,13 +190,13 @@ export class Equation implements
|
|
|
191
190
|
* @param values
|
|
192
191
|
* @param asNumeric
|
|
193
192
|
*/
|
|
194
|
-
public evaluate(values: InputValue<Fraction> | literalType<number | Fraction>, asNumeric
|
|
193
|
+
public evaluate(values: InputValue<Fraction> | literalType<number | Fraction>, asNumeric: boolean): boolean {
|
|
195
194
|
// Evaluate the left and right part of the equation.
|
|
196
195
|
// compare the results.
|
|
197
196
|
|
|
198
197
|
// Evaluate the left and right part of the equation.
|
|
199
|
-
const left = this.#left.evaluate(values, asNumeric)
|
|
200
|
-
|
|
198
|
+
const left = this.#left.evaluate(values, asNumeric)
|
|
199
|
+
const right = this.#right.evaluate(values, asNumeric)
|
|
201
200
|
|
|
202
201
|
// compare the results.
|
|
203
202
|
if (asNumeric) {
|
|
@@ -227,8 +226,8 @@ export class Equation implements
|
|
|
227
226
|
|
|
228
227
|
// Equations helpers
|
|
229
228
|
public isEqualTo = (equ: Equation): boolean => {
|
|
230
|
-
const p1 = equ.clone().moveLeft().left
|
|
231
|
-
|
|
229
|
+
const p1 = equ.clone().moveLeft().left
|
|
230
|
+
const p2 = this.clone().moveLeft().left
|
|
232
231
|
|
|
233
232
|
// They are the same.
|
|
234
233
|
return p1.isEqual(p2) || p1.isOppositeAt(p2)
|
|
@@ -236,8 +235,8 @@ export class Equation implements
|
|
|
236
235
|
|
|
237
236
|
public isLinearTo = (equ: Equation): boolean => {
|
|
238
237
|
// Move all left.
|
|
239
|
-
const p1 = equ.clone().moveLeft().simplify().left
|
|
240
|
-
|
|
238
|
+
const p1 = equ.clone().moveLeft().simplify().left
|
|
239
|
+
const p2 = this.clone().moveLeft().simplify().left
|
|
241
240
|
|
|
242
241
|
// They are the same.
|
|
243
242
|
return p1.isEqual(p2) || p1.isOppositeAt(p2)
|
|
@@ -427,7 +426,7 @@ export class Equation implements
|
|
|
427
426
|
// Set the sign value as formatted.
|
|
428
427
|
this.#sign = this.#formatSign(value)
|
|
429
428
|
}
|
|
430
|
-
|
|
429
|
+
|
|
431
430
|
public get signAsTex(): string {
|
|
432
431
|
if (this.#sign === '>=') {
|
|
433
432
|
return '\\geq'
|
|
@@ -480,7 +479,7 @@ export class Equation implements
|
|
|
480
479
|
}
|
|
481
480
|
|
|
482
481
|
public test = (values: literalType<Fraction>): boolean => {
|
|
483
|
-
return (this.left.evaluate(values)
|
|
482
|
+
return (this.left.evaluate(values)).isEqual(this.right.evaluate(values))
|
|
484
483
|
}
|
|
485
484
|
|
|
486
485
|
public get variables(): string[] {
|
package/src/algebra/factor.ts
CHANGED
|
@@ -216,6 +216,17 @@ export class Factor implements IPiMathObject<Factor>,
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
public multiply(value: InputAlgebra<Factor | Polynom>): this {
|
|
219
|
+
const F = new Factor(value)
|
|
220
|
+
|
|
221
|
+
// Case if this and value are monoms of degree one.
|
|
222
|
+
if(this.polynom.monoms.length===1 && this.power.isOne()
|
|
223
|
+
&&
|
|
224
|
+
F.polynom.monoms.length===1 && this.power.isOne()
|
|
225
|
+
){
|
|
226
|
+
this.polynom.multiply(F.polynom)
|
|
227
|
+
return this
|
|
228
|
+
}
|
|
229
|
+
|
|
219
230
|
if (value instanceof Factor) {
|
|
220
231
|
if (this.isSameAs(value)) {
|
|
221
232
|
this.power.add(value.power)
|
|
@@ -468,10 +468,29 @@ export class PolyFactor implements IPiMathObject<PolyFactor>,
|
|
|
468
468
|
.map(f => {
|
|
469
469
|
const base = f[0].polynom
|
|
470
470
|
const power = f.reduce((acc, f) => acc.add(f.power), new Fraction('0'))
|
|
471
|
+
|
|
471
472
|
return new Factor(base, power.reduce())
|
|
472
473
|
})
|
|
473
474
|
.filter(f => !f.power.isZero())
|
|
474
475
|
|
|
476
|
+
// Everything is reduced - merge all monomial factors together.
|
|
477
|
+
const numfactor = new Factor(1)
|
|
478
|
+
const denfactor = new Factor(1)
|
|
479
|
+
const monomials = this.#factors.filter(x=>x.polynom.monoms.length===1 && x.power.isRelative())
|
|
480
|
+
if(monomials.length>0){
|
|
481
|
+
monomials.forEach(m=> {
|
|
482
|
+
if(m.power.isPositive()){
|
|
483
|
+
numfactor.multiply(new Factor(m.polynom.clone().pow(m.power.value)))
|
|
484
|
+
}else{
|
|
485
|
+
denfactor.multiply(new Factor(m.polynom.clone().pow(-m.power.value)))
|
|
486
|
+
}
|
|
487
|
+
})
|
|
488
|
+
|
|
489
|
+
this.#factors = this.#factors.filter(x=>!(x.polynom.monoms.length===1 && x.power.isRelative()))
|
|
490
|
+
if (!denfactor.polynom.isOne()){this.#factors.push(denfactor.inverse())}
|
|
491
|
+
if (!numfactor.polynom.isOne()){this.#factors.push(numfactor)}
|
|
492
|
+
}
|
|
493
|
+
|
|
475
494
|
return this
|
|
476
495
|
}
|
|
477
496
|
|
|
@@ -487,6 +506,9 @@ export class PolyFactor implements IPiMathObject<PolyFactor>,
|
|
|
487
506
|
* 3. power of polyfactor
|
|
488
507
|
*/
|
|
489
508
|
public sort(letter?: string): this {
|
|
509
|
+
// Sort each polynom
|
|
510
|
+
this.#factors.forEach(f=>f.polynom.reorder(letter))
|
|
511
|
+
|
|
490
512
|
this.#factors.sort((a, b) => {
|
|
491
513
|
// If the compare powers are opposite, the negative power goes to the end.
|
|
492
514
|
const aPower = a.power.value
|
|
@@ -495,7 +517,6 @@ export class PolyFactor implements IPiMathObject<PolyFactor>,
|
|
|
495
517
|
return -aPower
|
|
496
518
|
}
|
|
497
519
|
|
|
498
|
-
|
|
499
520
|
// Monom length
|
|
500
521
|
const aLength = a.polynom.monoms.length
|
|
501
522
|
const bLength = b.polynom.monoms.length
|
|
@@ -515,6 +536,14 @@ export class PolyFactor implements IPiMathObject<PolyFactor>,
|
|
|
515
536
|
return aPower - bPower
|
|
516
537
|
}
|
|
517
538
|
|
|
539
|
+
// It the monoms length are two AND of degree one, sort by the zero.
|
|
540
|
+
if(a.polynom.degree(letter).isOne() && b.polynom.degree(letter).isOne()){
|
|
541
|
+
const aSol = a.polynom.monoms[1].coefficient.clone().opposite().divide(a.polynom.monoms[0].coefficient).value
|
|
542
|
+
const bSol = b.polynom.monoms[1].coefficient.clone().opposite().divide(b.polynom.monoms[0].coefficient).value
|
|
543
|
+
|
|
544
|
+
return aSol - bSol
|
|
545
|
+
}
|
|
546
|
+
|
|
518
547
|
return a.degree().isLeq(b.degree()) ? -1 : 1
|
|
519
548
|
})
|
|
520
549
|
|
|
@@ -648,12 +677,15 @@ function keyFactors(value: PolyFactor): Record<string, Factor[]> {
|
|
|
648
677
|
|
|
649
678
|
const kF = value.factors
|
|
650
679
|
.reduce((acc: Record<string, Factor[]>, f) => {
|
|
651
|
-
// It's only a value
|
|
652
|
-
|
|
680
|
+
// It's only a value (without roots
|
|
681
|
+
// TODO: implement reduce root numeric.
|
|
682
|
+
if (f.polynom.degree().isZero() && f.power.isRelative()) {
|
|
683
|
+
const value = f.polynom.monoms[0].coefficient.pow(f.power.clone().abs())
|
|
684
|
+
|
|
653
685
|
if (f.power.isPositive()) {
|
|
654
|
-
k_numerator.multiply(
|
|
686
|
+
k_numerator.multiply(value)
|
|
655
687
|
} else {
|
|
656
|
-
k_denominator.multiply(
|
|
688
|
+
k_denominator.multiply(value)
|
|
657
689
|
}
|
|
658
690
|
|
|
659
691
|
return acc
|
package/src/algebra/polynom.ts
CHANGED
|
@@ -136,7 +136,7 @@ export class Polynom implements IPiMathObject<Polynom>,
|
|
|
136
136
|
|
|
137
137
|
for (const value of values) {
|
|
138
138
|
if (value instanceof Polynom) {
|
|
139
|
-
this.#monoms = this.#monoms.concat(value.monoms.map(m=>m.clone()))
|
|
139
|
+
this.#monoms = this.#monoms.concat(value.monoms.map(m => m.clone()))
|
|
140
140
|
} else if (value instanceof Monom) {
|
|
141
141
|
this.#monoms.push(value.clone())
|
|
142
142
|
} else if (typeof value === "number" && Number.isSafeInteger(value)) {
|
|
@@ -279,8 +279,11 @@ export class Polynom implements IPiMathObject<Polynom>,
|
|
|
279
279
|
return {quotient, reminder}
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
public evaluate(values: literalType<Fraction | number> | InputValue<Fraction>, asNumeric: true): number
|
|
283
|
+
public evaluate(values: literalType<Fraction | number> | InputValue<Fraction>, asNumeric?: false): Fraction
|
|
284
|
+
public evaluate(values: literalType<Fraction | number> | InputValue<Fraction>, asNumeric?: boolean): Fraction | number
|
|
282
285
|
public evaluate(values: literalType<Fraction | number> | InputValue<Fraction>, asNumeric?: boolean): Fraction | number {
|
|
283
|
-
// Return the numeric value
|
|
286
|
+
// Return the numeric value without using Fraction
|
|
284
287
|
if (asNumeric) {
|
|
285
288
|
return this.#evaluateAsNumeric(values)
|
|
286
289
|
}
|
|
@@ -304,7 +307,7 @@ export class Polynom implements IPiMathObject<Polynom>,
|
|
|
304
307
|
this.#factors = []
|
|
305
308
|
|
|
306
309
|
// There is only one monom - it's already considered as factor.
|
|
307
|
-
if(this.monoms.length===1) return [this.clone()]
|
|
310
|
+
if (this.monoms.length === 1) return [this.clone()]
|
|
308
311
|
|
|
309
312
|
let P = this.clone().reorder()
|
|
310
313
|
|
|
@@ -400,7 +403,7 @@ export class Polynom implements IPiMathObject<Polynom>,
|
|
|
400
403
|
const orderedPolynom = this.clone().reorder()
|
|
401
404
|
|
|
402
405
|
const length = this.degree().value + 1
|
|
403
|
-
const coeffs = Array.from({length}, ()=>new Fraction(0))
|
|
406
|
+
const coeffs = Array.from({length}, () => new Fraction(0))
|
|
404
407
|
|
|
405
408
|
orderedPolynom.monoms.forEach(monom => {
|
|
406
409
|
const index = length - monom.degree().value - 1
|
|
@@ -445,13 +448,13 @@ export class Polynom implements IPiMathObject<Polynom>,
|
|
|
445
448
|
public integrate(a: InputValue<Fraction>, b: InputValue<Fraction>, letter = 'x'): Fraction {
|
|
446
449
|
const primitive = this.primitive(letter)
|
|
447
450
|
|
|
448
|
-
const valuesA: literalType<Fraction> = {}
|
|
449
|
-
|
|
451
|
+
const valuesA: literalType<Fraction> = {}
|
|
452
|
+
const valuesB: literalType<Fraction> = {}
|
|
450
453
|
|
|
451
454
|
valuesA[letter] = new Fraction(a)
|
|
452
455
|
valuesB[letter] = new Fraction(b)
|
|
453
456
|
|
|
454
|
-
return (primitive.evaluate(valuesB)
|
|
457
|
+
return (primitive.evaluate(valuesB)).subtract(primitive.evaluate(valuesA))
|
|
455
458
|
}
|
|
456
459
|
|
|
457
460
|
public inverse(): Polynom | undefined {
|
|
@@ -494,7 +497,7 @@ export class Polynom implements IPiMathObject<Polynom>,
|
|
|
494
497
|
const zero = div.getZeroes()[0]
|
|
495
498
|
|
|
496
499
|
if (zero.exact) {
|
|
497
|
-
return (this.evaluate(zero.fraction)
|
|
500
|
+
return (this.evaluate(zero.fraction)).isZero()
|
|
498
501
|
} else {
|
|
499
502
|
return false
|
|
500
503
|
}
|
|
@@ -548,7 +551,7 @@ export class Polynom implements IPiMathObject<Polynom>,
|
|
|
548
551
|
// Finite value: evaluate directly
|
|
549
552
|
if (f.isFinite()) {
|
|
550
553
|
const l = letter ?? this.variables[0] ?? 'x'
|
|
551
|
-
return this.evaluate({[l]: f})
|
|
554
|
+
return this.evaluate({[l]: f})
|
|
552
555
|
}
|
|
553
556
|
|
|
554
557
|
const M = this.monomByDegree(undefined, letter)
|
|
@@ -747,8 +750,8 @@ export class Polynom implements IPiMathObject<Polynom>,
|
|
|
747
750
|
public reorder(letter = 'x', revert = false): this {
|
|
748
751
|
const otherLetters = this.variables.filter(x => x !== letter)
|
|
749
752
|
this.#monoms.sort(function (a, b) {
|
|
750
|
-
const da = a.degree(letter).value
|
|
751
|
-
|
|
753
|
+
const da = a.degree(letter).value
|
|
754
|
+
const db = b.degree(letter).value
|
|
752
755
|
|
|
753
756
|
// Values are different
|
|
754
757
|
if (da !== db) {
|
|
@@ -758,8 +761,8 @@ export class Polynom implements IPiMathObject<Polynom>,
|
|
|
758
761
|
// if values are equals, check other letters - it must be reverted in that case !
|
|
759
762
|
if (otherLetters.length > 0) {
|
|
760
763
|
for (const L of otherLetters) {
|
|
761
|
-
const da = a.degree(L).value
|
|
762
|
-
|
|
764
|
+
const da = a.degree(L).value
|
|
765
|
+
const db = b.degree(L).value
|
|
763
766
|
|
|
764
767
|
// Values are different
|
|
765
768
|
if (da !== db) {
|
|
@@ -889,7 +892,7 @@ export class Polynom implements IPiMathObject<Polynom>,
|
|
|
889
892
|
]
|
|
890
893
|
|
|
891
894
|
testingRoots.forEach((test, index) => {
|
|
892
|
-
const sign = this.evaluate({[this.variables[0] ?? 'x']: test}, true)
|
|
895
|
+
const sign = this.evaluate({[this.variables[0] ?? 'x']: test}, true)
|
|
893
896
|
signs[index * 2] = sign > 0 ? '+' : '-'
|
|
894
897
|
})
|
|
895
898
|
}
|
|
@@ -1128,8 +1131,8 @@ export class Polynom implements IPiMathObject<Polynom>,
|
|
|
1128
1131
|
|
|
1129
1132
|
case ShutingyardType.OPERATION:
|
|
1130
1133
|
if (stack.length >= 2) {
|
|
1131
|
-
const b = stack.pop()
|
|
1132
|
-
|
|
1134
|
+
const b = stack.pop()
|
|
1135
|
+
const a = stack.pop()
|
|
1133
1136
|
|
|
1134
1137
|
// Check if the polynoms are not undefined.
|
|
1135
1138
|
if (a === undefined || b === undefined) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EQUATION_SIGN, IAlgebra, IEquation, InputAlgebra, InputValue, IPiMathObject, literalType } from
|
|
2
|
-
import { Fraction } from
|
|
3
|
-
import { Polynom } from
|
|
4
|
-
import { Solution } from
|
|
1
|
+
import type { EQUATION_SIGN, IAlgebra, IEquation, InputAlgebra, InputValue, IPiMathObject, literalType } from "../pimath.interface";
|
|
2
|
+
import { Fraction } from "../coefficients";
|
|
3
|
+
import { Polynom } from "./polynom";
|
|
4
|
+
import type { Solution } from "../analyze";
|
|
5
5
|
export declare class Equation implements IPiMathObject<Equation>, IEquation<Equation>, IAlgebra<Equation> {
|
|
6
6
|
#private;
|
|
7
7
|
constructor(equation: InputAlgebra<Polynom> | Equation);
|
|
@@ -12,71 +12,21 @@ export declare class Equation implements IPiMathObject<Equation>, IEquation<Equa
|
|
|
12
12
|
get display(): string;
|
|
13
13
|
static isEquationString(equationString: string): boolean;
|
|
14
14
|
static makeSolutionsUnique(solutions: Solution[], sorted?: boolean): Solution[];
|
|
15
|
-
/**
|
|
16
|
-
* Add a value to the equation
|
|
17
|
-
* if value is an equation, add the left part to the left part of the equation
|
|
18
|
-
* and the right part to the right part of the equation
|
|
19
|
-
* if value is a string, try to create an equation
|
|
20
|
-
* if it fails, create a polynom and add it to the left and right part of the equation
|
|
21
|
-
* @param value | Polynom | Monom | Fraction | string | monom
|
|
22
|
-
*/
|
|
23
15
|
add(value: InputValue<Equation | Polynom>): this;
|
|
24
16
|
create: (left: Polynom, right: Polynom, sign?: string) => this;
|
|
25
|
-
/**
|
|
26
|
-
* Get the degree of the equation
|
|
27
|
-
* @param letter
|
|
28
|
-
*/
|
|
29
17
|
degree: (letter?: string) => Fraction;
|
|
30
|
-
/**
|
|
31
|
-
* divide an equation by a given value (transformed as a fraction)
|
|
32
|
-
*
|
|
33
|
-
* ```
|
|
34
|
-
* 8x+10=6x \vert 2
|
|
35
|
-
* 4x+5=3x
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* |>Alternatively with $3x-4$ maybe it's working ?
|
|
39
|
-
* $$\frac{3x}{5}$$
|
|
40
|
-
*
|
|
41
|
-
* @param value
|
|
42
|
-
* @returns {Equation}
|
|
43
|
-
*/
|
|
44
18
|
divide: (value: InputValue<Fraction>) => this;
|
|
45
|
-
|
|
46
|
-
* Create an Equation using two polynoms.
|
|
47
|
-
* Markdown *support* is cool
|
|
48
|
-
* @param values
|
|
49
|
-
* @param asNumeric
|
|
50
|
-
*/
|
|
51
|
-
evaluate(values: InputValue<Fraction> | literalType<number | Fraction>, asNumeric?: boolean): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Determine if the equation contains a variable.
|
|
54
|
-
* @param letter
|
|
55
|
-
*/
|
|
19
|
+
evaluate(values: InputValue<Fraction> | literalType<number | Fraction>, asNumeric: boolean): boolean;
|
|
56
20
|
hasVariable: (letter: string) => boolean;
|
|
57
21
|
isEqual(value: InputValue<Equation>): boolean;
|
|
58
22
|
isEqualTo: (equ: Equation) => boolean;
|
|
59
23
|
isLinearTo: (equ: Equation) => boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Determine if the equation contains more than one letter/variable.
|
|
62
|
-
*/
|
|
63
24
|
isMultiVariable: () => boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Reorder the polynom to have only one letter on the left, the rest on the right.
|
|
66
|
-
* @param letter
|
|
67
|
-
*/
|
|
68
25
|
isolate: (letter?: string) => this | false;
|
|
69
26
|
get left(): Polynom;
|
|
70
27
|
set left(value: Polynom);
|
|
71
28
|
letters: () => string[];
|
|
72
|
-
/**
|
|
73
|
-
* Reorder will move all monoms containing a letter on the left, all the other on the right.
|
|
74
|
-
*/
|
|
75
29
|
moveLeft: () => this;
|
|
76
|
-
/**
|
|
77
|
-
* Multiple an equation by a fraction value.
|
|
78
|
-
* @param value
|
|
79
|
-
*/
|
|
80
30
|
multiply: (value: InputValue<Fraction>) => this;
|
|
81
31
|
get numberOfVars(): number;
|
|
82
32
|
opposite: () => this;
|
|
@@ -89,9 +39,6 @@ export declare class Equation implements IPiMathObject<Equation>, IEquation<Equa
|
|
|
89
39
|
get sign(): string;
|
|
90
40
|
set sign(value: string);
|
|
91
41
|
get signAsTex(): string;
|
|
92
|
-
/**
|
|
93
|
-
* Multiply by the lcm denominator and divide by the gcm numerators.
|
|
94
|
-
*/
|
|
95
42
|
simplify: () => this;
|
|
96
43
|
solve: () => Solution[];
|
|
97
44
|
split(): [Polynom, Polynom];
|
|
@@ -99,3 +46,4 @@ export declare class Equation implements IPiMathObject<Equation>, IEquation<Equa
|
|
|
99
46
|
test: (values: literalType<Fraction>) => boolean;
|
|
100
47
|
get variables(): string[];
|
|
101
48
|
}
|
|
49
|
+
//# sourceMappingURL=equation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equation.d.ts","sourceRoot":"","sources":["../../src/algebra/equation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,aAAa,EACb,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,aAAa,EACb,WAAW,EACd,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAC,QAAQ,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"equation.d.ts","sourceRoot":"","sources":["../../src/algebra/equation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,aAAa,EACb,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,aAAa,EACb,WAAW,EACd,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAA;AAIxC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AAExC,qBAAa,QAAS,YAAW,aAAa,CAAC,QAAQ,CAAC,EACpD,SAAS,CAAC,QAAQ,CAAC,EACnB,QAAQ,CAAC,QAAQ,CAAC;;gBAUN,QAAQ,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,QAAQ;gBAC1C,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,aAAa;IA8BpF,KAAK,GAAI,gBAAgB,MAAM,KAAG,IAAI,CAY5C;IAEM,KAAK,QAAO,QAAQ,CAE1B;IAED,IAAW,GAAG,IAAI,MAAM,CAEvB;IAED,IAAW,OAAO,IAAI,MAAM,CAE3B;WAEa,gBAAgB,CAAC,cAAc,EAAE,MAAM,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AI,UAAU,OAAO,KAAG,IAAI,CAyBzC;IAGM,SAAS,GAAI,QAAQ,MAAM,EAAE,GAAG,OAAO,KAAG,IAAI,CAIpD;IAED,IAAW,KAAK,IAAI,OAAO,CAE1B;IAED,IAAW,KAAK,CAAC,KAAK,EAAE,OAAO,EAE9B;IAGD,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,IAAI,CAAC,KAAK,EAAE,MAAM,EAG5B;IAED,IAAW,SAAS,IAAI,MAAM,CAU7B;IAKM,QAAQ,QAAO,IAAI,CAIzB;IAGM,KAAK,QAAO,QAAQ,EAAE,CAG5B;IAEM,KAAK,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;IAI3B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,IAAI;IAoBrD,IAAI,GAAI,QAAQ,WAAW,CAAC,QAAQ,CAAC,KAAG,OAAO,CAErD;IAED,IAAW,SAAS,IAAI,MAAM,EAAE,CAE/B;CAsEJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Polynom } from
|
|
2
|
-
import { Equation } from
|
|
3
|
-
import { Solution } from
|
|
1
|
+
import type { Polynom } from "./polynom";
|
|
2
|
+
import type { Equation } from "./equation";
|
|
3
|
+
import { Solution } from "../analyze";
|
|
4
4
|
export declare class EquationSolver {
|
|
5
5
|
#private;
|
|
6
6
|
_: number;
|
|
@@ -11,3 +11,4 @@ export declare class EquationSolver {
|
|
|
11
11
|
solve(): Solution[];
|
|
12
12
|
solveAsCardan(): Solution[];
|
|
13
13
|
}
|
|
14
|
+
//# sourceMappingURL=equationSolver.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IAlgebra, IExpression, InputAlgebra, InputValue, IPiMathObject, literalType, TABLE_OF_SIGNS } from
|
|
2
|
-
import { Fraction } from
|
|
3
|
-
import { Polynom } from
|
|
1
|
+
import type { IAlgebra, IExpression, InputAlgebra, InputValue, IPiMathObject, literalType, TABLE_OF_SIGNS } from "../pimath.interface";
|
|
2
|
+
import { Fraction } from "../coefficients/fraction";
|
|
3
|
+
import { Polynom } from "./polynom";
|
|
4
4
|
export declare class Factor implements IPiMathObject<Factor>, IExpression<Factor>, IAlgebra<Factor> {
|
|
5
5
|
#private;
|
|
6
6
|
constructor(value?: InputAlgebra<Polynom> | Factor, power?: InputValue<Fraction>);
|
|
@@ -47,3 +47,4 @@ export declare enum FACTOR_DISPLAY {
|
|
|
47
47
|
ROOT = 0,
|
|
48
48
|
POWER = 1
|
|
49
49
|
}
|
|
50
|
+
//# sourceMappingURL=factor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factor.d.ts","sourceRoot":"","sources":["../../src/algebra/factor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,EACb,WAAW,EACX,cAAc,EACjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAGjC,qBAAa,MAAO,YAAW,aAAa,CAAC,MAAM,CAAC,EAChD,WAAW,CAAC,MAAM,CAAC,EACnB,QAAQ,CAAC,MAAM,CAAC;;gBAMJ,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC;IAsBzE,KAAK,IAAiC,MAAM;IAI5C,KAAK,IAAI,MAAM;IAItB,IAAW,GAAG,IAAI,MAAM,CAyBvB;IAED,IAAW,OAAO,IAAI,MAAM,CAyB3B;IAEM,GAAG,IAAI,MAAM;IAIpB,IAAW,QAAQ,IAAI,IAAI,CAG1B;IAEM,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ;IAIjC,UAAU,IAAI,MAAM,EAAE;IAoBtB,OAA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B,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKzB,IAAI,IAAI,IAAI;IAIZ,QAAQ,IAAI,MAAM;IAIlB,YAAY,IAAI,cAAc;IAwBrC,IAAW,SAAS,IAAI,MAAM,EAAE,CAE/B;IAED,IAAW,SAAS,IAAI,IAAI,CAG3B;IAED,IAAW,QAAQ,IAAI,IAAI,CAG1B;IAEM,IAAI,IAAI,IAAI;IAMnB,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAYhD,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,UAAO,GAAG,MAAM,EAAE;CA8BxE;AAED,oBAAY,cAAc;IACtB,IAAI,IAAA;IACJ,KAAK,IAAA;CACR"}
|
package/types/algebra/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IAlgebra, IEquation, InputValue, IPiMathObject, literalType } from
|
|
2
|
-
import { Fraction } from
|
|
3
|
-
import { Equation } from
|
|
4
|
-
import { Polynom } from
|
|
5
|
-
import { Solution } from
|
|
1
|
+
import type { IAlgebra, IEquation, InputValue, IPiMathObject, literalType } from "../pimath.interface";
|
|
2
|
+
import { Fraction } from "../coefficients";
|
|
3
|
+
import { Equation } from "./equation";
|
|
4
|
+
import { Polynom } from "./polynom";
|
|
5
|
+
import { Solution } from "../analyze";
|
|
6
6
|
export declare class LinearSystem implements IPiMathObject<LinearSystem>, IEquation<LinearSystem>, IAlgebra<LinearSystem> {
|
|
7
7
|
#private;
|
|
8
8
|
constructor(...values: (string | Equation)[]);
|
|
@@ -48,3 +48,4 @@ export declare class LinearSystem implements IPiMathObject<LinearSystem>, IEquat
|
|
|
48
48
|
get variables(): string[];
|
|
49
49
|
set variables(value: string | string[]);
|
|
50
50
|
}
|
|
51
|
+
//# sourceMappingURL=linearSystem.d.ts.map
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Polynom class can handle polynoms, reorder, resolve, ...
|
|
3
|
-
*/
|
|
4
1
|
export declare class LogicalSet {
|
|
5
2
|
#private;
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {string} value (optional) Default polynom to parse on class creation
|
|
9
|
-
*/
|
|
10
3
|
constructor(value?: string);
|
|
11
4
|
parse: (value: string) => this;
|
|
12
5
|
get tex(): string;
|
|
@@ -19,3 +12,4 @@ export declare class LogicalSet {
|
|
|
19
12
|
vennAB(): string[];
|
|
20
13
|
vennABC(): string[];
|
|
21
14
|
}
|
|
15
|
+
//# sourceMappingURL=logicalset.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IExpressionMultiply, InputAlgebra, InputValue, IPiMathObject } from
|
|
2
|
-
import { Polynom } from
|
|
3
|
-
import { Vector } from
|
|
1
|
+
import type { IExpressionMultiply, InputAlgebra, InputValue, IPiMathObject } from "../pimath.interface";
|
|
2
|
+
import { Polynom } from "./polynom";
|
|
3
|
+
import type { Vector } from "../geometry";
|
|
4
4
|
export type IMatrixValues = InputAlgebra<Polynom>[][];
|
|
5
5
|
export declare class Matrix implements IPiMathObject<Matrix>, IExpressionMultiply<Matrix> {
|
|
6
6
|
#private;
|
|
@@ -49,3 +49,4 @@ export declare class Matrix implements IPiMathObject<Matrix>, IExpressionMultipl
|
|
|
49
49
|
get values(): Polynom[][];
|
|
50
50
|
zero(): this;
|
|
51
51
|
}
|
|
52
|
+
//# sourceMappingURL=matrix.d.ts.map
|