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,72 +0,0 @@
1
- import {Expression, ExpressionFactor} from "../internals";
2
-
3
- export class ExpFactorNumber extends ExpressionFactor {
4
- private _number: number
5
-
6
- constructor(value: number, power?: number, root?: number) {
7
- super(null, power, root);
8
-
9
- if (typeof value !== "number") {
10
- throw `The number ${value} is not a valid value.`
11
- }
12
-
13
- this._number = value
14
- }
15
-
16
- get value(): number {
17
- return Math.pow(this._number, this.root / this.root)
18
- }
19
-
20
- get number(): number {
21
- return this._number
22
- }
23
-
24
-
25
- set number(value: number) {
26
- this._number = value;
27
- }
28
-
29
- makeTeX(): string {
30
- return this.texPower(this.texRoot(this._number.toString()))
31
- }
32
-
33
- makeDisplay(numberOfFactors?: number, position?: number): string {
34
- return this.displayPower(this.displayRoot(this._number.toString()))
35
- }
36
-
37
- derivative(variable: string): Expression {
38
- return undefined;
39
- }
40
-
41
- integrate(variable: string): Expression {
42
- return undefined;
43
- }
44
-
45
- hasVariable(variable?: string): boolean {
46
- return false
47
- }
48
-
49
- reduce(): ExpressionFactor {
50
- // Reduce the power / root value
51
- super.reduce()
52
-
53
- if (this.power > 1) {
54
- this.number = this.number ** this.power
55
- this.power = 1
56
- }
57
- if (this.power < -1) {
58
- this.number = this.number ** (-this.power)
59
- this.power = -1
60
- }
61
-
62
- if(this.root>1){
63
- // Maybe it's a perfect root ?
64
- if(Number.isSafeInteger(Math.pow(this.number, 1/this.root))){
65
- this.number = Math.pow(this.number, 1/this.root)
66
- this.root = 1
67
- }
68
- }
69
-
70
- return this
71
- }
72
- }
@@ -1,42 +0,0 @@
1
- import {Expression} from "../internals";
2
- import {ExpressionFactor} from "../internals";
3
-
4
- export class ExpFactorPower extends ExpressionFactor {
5
- get powerArgument(): Expression {
6
- return this._powerArgument;
7
- }
8
-
9
- set powerArgument(value: Expression) {
10
- this._powerArgument = value;
11
- }
12
-
13
- private _powerArgument: Expression
14
- constructor(radical: Expression, power: Expression, power2?: number, root?:number) {
15
- super(radical, power2, root);
16
-
17
- this._powerArgument = power
18
- }
19
- derivative(variable: string): Expression {
20
- return undefined
21
- }
22
-
23
- integrate(variable: string): Expression {
24
- return undefined
25
- }
26
-
27
- makeTeX(): string {
28
- let tex: string = `{ ${ this.argument.tex } }^{ ${this._powerArgument.tex } }`
29
-
30
- return this.texPowerAndRoot(this.wrapWithParentheses(tex))
31
- }
32
-
33
- getArguments(): Expression[] {
34
- return [this.argument, this.powerArgument]
35
- }
36
-
37
- makeDisplay(numberOfFactors?: number, position?: number): string {
38
- let display: string = `( ${ this.argument.display } )^( ${this._powerArgument.display } )`
39
-
40
- return this.displayPowerAndRoot(this.wrapWithParentheses(display, false))
41
- }
42
- }
@@ -1,53 +0,0 @@
1
- import {Expression} from "../internals";
2
- import {ExpressionFactor} from "../internals";
3
-
4
- export enum TRIGONOMETRIC {
5
- sin='sin',
6
- cos='cos',
7
- tan='tan',
8
- cot='cot',
9
- asin='asin',
10
- atan='atan',
11
- acos='acos',
12
- acot='acot'
13
- }
14
- export class ExpFactorTrigo extends ExpressionFactor {
15
- private _trigo: string
16
- constructor(trigo: string, argument: Expression, power?: number, root?: number) {
17
-
18
- super(argument, power, root);
19
-
20
- if(! (trigo in TRIGONOMETRIC)){
21
- throw `The ${ trigo } is not a valid trigonometric function.`
22
- }
23
-
24
- this._trigo = trigo
25
- }
26
- derivative(variable: string): Expression {
27
- return undefined
28
- }
29
-
30
- integrate(variable: string): Expression {
31
- return undefined
32
- }
33
-
34
- makeTeX(): string {
35
- let tex = `\\${this._trigo}`
36
- if(this.root>1){
37
- tex += `^{ ${this.root} }`
38
- }
39
-
40
- tex+= `\\left( ${this.argument.tex} \\right)`
41
- return this.texRoot(tex);
42
- }
43
-
44
- makeDisplay(numberOfFactors?: number, position?: number): string {
45
- let display = `${this._trigo}`
46
- if(this.root>1){
47
- display += `^( ${this.root} )`
48
- }
49
-
50
- display+= `( ${this.argument.display} )`
51
- return this.displayRoot(display);
52
- }
53
- }
@@ -1,45 +0,0 @@
1
- import {Expression} from "../internals";
2
- import {ExpressionFactor} from "../internals";
3
-
4
- export class ExpFactorVariable extends ExpressionFactor {
5
- private _variable: string
6
- constructor(value: string, power?: number, root?: number) {
7
- super(null, power, root);
8
-
9
- if (typeof value !== "string") {
10
- throw `The variable ${value} is not a valid value.`
11
- }
12
-
13
- this._variable = value
14
- }
15
-
16
-
17
- get variable(): string {
18
- return this._variable;
19
- }
20
-
21
- set variable(value: string) {
22
- this._variable = value;
23
- }
24
-
25
- makeTeX(): string {
26
- return this.texPower(this.texRoot(this._variable))
27
- }
28
-
29
- makeDisplay(numberOfFactors?: number, position?: number): string {
30
- return this.displayPower(this.displayRoot(this._variable))
31
- }
32
-
33
-
34
- derivative(variable: string): Expression {
35
- return undefined;
36
- }
37
-
38
- integrate(variable: string): Expression {
39
- return undefined;
40
- }
41
-
42
- hasVariable(variable?: string): boolean {
43
- return this._variable === variable
44
- }
45
- }
@@ -1,14 +0,0 @@
1
- export * from "./expression"
2
- export * from "./expressionParser"
3
- export * from "./expressionMember"
4
-
5
- export * from "./expressionFactor"
6
- export * from "./factors/ExpFactor"
7
- export * from "./factors/ExpFactorConstant"
8
- export * from "./factors/ExpFactorExponential"
9
- export * from "./factors/ExpFactorNumber"
10
- export * from "./factors/ExpFactorPower"
11
- export * from "./factors/ExpFactorTrigo"
12
- export * from "./factors/ExpFactorVariable"
13
-
14
- export * from "../shutingyard"
@@ -1,221 +0,0 @@
1
- import {Polynom} from "../algebra/polynom";
2
- import {Fraction} from "../coefficients/fraction";
3
-
4
- type Factor = {
5
- polynom: Polynom,
6
- degree: Fraction
7
- }
8
-
9
- export function isFactor(value: any): value is Factor {
10
- return value && 'polynom' in value && 'degree' in value
11
- }
12
-
13
- export class PolynomExpFactor {
14
- constructor(...values: unknown[]) {
15
- this._powerAsInteger = true
16
- this._factors = []
17
-
18
- for (let factor of values) {
19
- if (isFactor(factor)) {
20
- this.addFactor({
21
- polynom: factor.polynom,
22
- degree: factor.degree
23
- })
24
- }
25
- }
26
- }
27
-
28
- private _factors: Factor[]
29
-
30
- get factors(): Factor[] {
31
- return this._factors;
32
- }
33
-
34
- private _powerAsInteger: boolean
35
-
36
- get powerAsInteger(): boolean {
37
- return this._powerAsInteger;
38
- }
39
-
40
- set powerAsInteger(value: boolean) {
41
- this._powerAsInteger = value;
42
- }
43
-
44
- get tex(): string {
45
- // group positive and negative degrees.
46
- const numerators: String[] = [],
47
- denominators: String[] = []
48
-
49
- for (const k of this._factors) {
50
- if (k.degree.isPositive()) {
51
- numerators.push(this._factorAsTex(k))
52
- } else {
53
- denominators.push(this._factorAsTex({
54
- polynom: k.polynom,
55
- degree: k.degree.clone().opposed()
56
- }))
57
- }
58
- }
59
-
60
- if (denominators.length > 0) {
61
- return `\\frac{ ${numerators.length > 0 ? numerators.join('') : 1} }{ ${denominators.join('')} }`
62
- } else {
63
- return numerators.join('')
64
- }
65
- }
66
-
67
- addFactor = (value: Factor): PolynomExpFactor => {
68
- this._factors.push({
69
- polynom: new Polynom(value.polynom),
70
- degree: new Fraction(value.degree)
71
- })
72
-
73
- return this
74
- }
75
-
76
- multiply = (value: PolynomExpFactor): PolynomExpFactor => {
77
- for (const k of value.factors) {
78
- this.addFactor(k)
79
- }
80
- return this
81
- }
82
-
83
- divide = (value: PolynomExpFactor): PolynomExpFactor => {
84
- for (const k of value.factors) {
85
- this.addFactor({
86
- polynom: k.polynom,
87
- degree: k.degree.clone().opposed()
88
- })
89
- }
90
- return this
91
- }
92
-
93
- derivative = (letter: string): PolynomExp => {
94
- // A*B*C*D =
95
-
96
- // Basic version
97
- // TODO: create derivative with more than only two factors.
98
- if (this._factors.length === 2) {
99
- const A = this._factors[0], B = this._factors[1],
100
- P = new PolynomExp()
101
- let Ad = this._factorDerivative(A),
102
- Bd = this._factorDerivative(B)
103
-
104
- P.add(
105
- new PolynomExpFactor(
106
- {
107
- polynom: A.polynom.derivative(letter),
108
- }
109
- )
110
- )
111
- }
112
- return
113
- }
114
-
115
- private _factorDerivative = (factor: Factor, letter?: string): PolynomExpFactor => {
116
- let derivativeExpression = new PolynomExpFactor()
117
- derivativeExpression.addFactor({polynom: new Polynom(factor.degree), degree: new Fraction().one()})
118
- derivativeExpression.addFactor({polynom: factor.polynom, degree: factor.degree.subtract(1)})
119
- derivativeExpression.addFactor({
120
- polynom: factor.polynom.clone().derivative(letter),
121
- degree: new Fraction().one()
122
- })
123
-
124
- return derivativeExpression
125
-
126
- }
127
-
128
- private _factorAsTex = (factor: Factor, withParenthesis?: Boolean): string => {
129
- let tex: string = ''
130
-
131
- if (factor.degree.isOne()) {
132
- if (withParenthesis === undefined || withParenthesis) {
133
- tex = `\\left(${factor.polynom.tex}\\right)`
134
- } else {
135
- tex = factor.polynom.tex
136
- }
137
- } else if (factor.degree.isNatural()) {
138
- tex = `\\left(${factor.polynom.tex}\\right)^{ ${factor.degree.tex} }`
139
- } else {
140
- if (this._powerAsInteger) {
141
- if (factor.degree.denominator === 2) {
142
- tex = `\\sqrt{${factor.polynom.tex}}`
143
- } else {
144
- tex = `\\sqrt[${factor.degree.denominator}]{${factor.polynom.tex}}`
145
- }
146
-
147
- if (factor.degree.numerator !== 1) {
148
- tex += `^{ ${factor.degree.numerator} }`
149
- }
150
- } else {
151
- tex = `\\left(${factor.polynom.tex}\\right)^{ ${factor.degree.tex} }`
152
- }
153
- }
154
- return tex
155
- }
156
- }
157
-
158
- export class PolynomExp {
159
- private _factors: { factors: PolynomExpFactor, positive: boolean }[]
160
-
161
- constructor(...values: PolynomExpFactor[]) {
162
- this._factors = []
163
- if (values !== undefined) {
164
- for (const factor of values) {
165
- this._factors.push({
166
- factors: factor,
167
- positive: true
168
- })
169
- }
170
- }
171
- this._powerAsInteger = true
172
- }
173
-
174
- private _powerAsInteger: boolean
175
-
176
- get powerAsInteger(): boolean {
177
- return this._powerAsInteger;
178
- }
179
-
180
- set powerAsInteger(value: boolean) {
181
- for (const factor of this._factors) {
182
- factor.factors.powerAsInteger = value
183
- }
184
- this._powerAsInteger = value;
185
- }
186
-
187
- get tex(): string {
188
- let tex = ''
189
-
190
- for (const factor of this._factors) {
191
- if (factor.factors.tex === '') {
192
- continue
193
- }
194
- if (tex !== '' || !factor.positive) {
195
- tex += factor.positive ? '+' : '-'
196
- }
197
- tex += factor.factors.tex
198
- }
199
-
200
-
201
- return tex
202
- }
203
-
204
- add = (value: PolynomExpFactor): PolynomExp => {
205
- value.powerAsInteger = this._powerAsInteger
206
- this._factors.push({
207
- factors: value,
208
- positive: true
209
- })
210
- return this
211
- }
212
-
213
- subtract = (value: PolynomExpFactor): PolynomExp => {
214
- value.powerAsInteger = this._powerAsInteger
215
- this._factors.push({
216
- factors: value,
217
- positive: false
218
- })
219
- return this
220
- }
221
- }