Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXACT MODE for matrix library <matrix.ts> #48

Open
Haise-Turquoise opened this issue Jul 20, 2020 · 3 comments
Open

EXACT MODE for matrix library <matrix.ts> #48

Haise-Turquoise opened this issue Jul 20, 2020 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Haise-Turquoise
Copy link

Haise-Turquoise commented Jul 20, 2020

Background

For calculation of the advanced linear algebra, the current data type of Hedgehog-lab(Ver0.4) cannot support the exact value calculation with square root like the image below:
matrix2

Topics

Exact-calculation mode (Exact Mode) for matrix library

My suggestion is creating the exact calculation mode which ONLY allows the input of fractions of integers and output of fractions of integers (no decimals allowed for IO of Exact Mode). Adding some new data types with the support of fractions and square root would probably have a conflict with the current data type.
However, this project can use [a mode button in the IO webpage] OR use [a global mode variable in the first few lines of the code compulsorily] to avoid the confusion of the decimal calculation and the exact calculation.

example of confusion:
2/sqrt(2) can be interpreted as 1.414... or sqrt(2) in the current and the exact mode of calculation.

After implementing the Exact-calculation mode of the matrix library, the following suggested function would provide a practical use for students and academic researchers.

Suggested functions for the matrix library
-linearly independence check
-determinant calculation
-row reduced echelon form simplification
-Find the basis for range(A), Row(A), Col(A), Null(transpose(A))
-coordinates of vector under different bases
-eigenvalue calculation
-matrix diagonalization

For the calculation functions below, Exact Mode is highly suggested for practical use
-length of vector
-the standard inner product for real matrix ("**" already implemented for current version but not for exact model)
-Gram-Schmidt Procedure
-set of bases vectors to an orthogonal matrix
-general mapping
-find basis of the orthogonal complement space
-matrix orthogonal diagonalization
-matrix triangularization
-singular value decomposition

@lidangzzz
Copy link
Member

@Haise-Turquoise I LOVE this idea!!! Actually I've already had an idea about how to implement this feature.

Here is my brainstorming: since we've already supported Nerdamer with compiler frontend (babel plugin operator overload for Symbolic class),
If you may try this script:

x = sym('1')
y = sym('4')
z = sym('7')
print(sin(y) + (z^0.5 ))

you may see that Nerdamer already helped us to support an exact mode with . For the exact mode matrix, we may initialize a matrix/vector/tensor by using:

A = new exactMat( [ [ cos( sym('1') ) + sqrt(sym('7')), sqrt(sym('5'))]] ) 

which would be a quite straight-forward approach. But I hope we may come up with a better idea to support this feature natively by babel parser. Do you have any ideas?

@Haise-Turquoise
Copy link
Author

Haise-Turquoise commented Jul 21, 2020

Thanks for your commenting.

I do not think using sym() function would solve the problem user-friendly. Because assuming that I need to input three 3x3 matrices, then I need to input sym() for 27 times. Using some helper function to transfer the mat class to exactmat class would be possible but it may still require users to call this helper function every time. There are two ways of dividing the calculation of exact mode and current mode: implementing the exactmat value into the mat and make the value wasted when currently is the decimal mode, or make the separate class mat and exactmat.
Because I do not have any experience of typescript or front-end or GPU generation or Babel parser, I am afraid I cannot provide specific suggestions about the language. But I can provide information about how to improve the matrix library and the abstract design of the exactmat.

In the user side, I would be glad to mention two things:
1-Name of exactmat() is too long for user. I suggest make it less or equal to 5 characters.
2-
The most user-friendly exact model input way is that:
let a =[-1/-sqt(2),-2/sqt(3),7/-sqt(6)] would be transferred to the corresponding version automatically. And note that by the possible conflict of sqrt() overriding, I used sqt(). Plus, the note that negative symbol friendly input.

In the developer side, the design of the exactmat value can be
Method1:

INTEGER nomi
INTEGER denom
BOOLEAN nomisqrt
BOOLEAN nomisqrt

Method2:

(Define type SQRTVAL by INT and BOOL)
SQRTVAL nomi
SQRTVAL denom

HOWEVER, the methods above, namely the type definitions of exactmat, are not concise enough or they are even misleading. I suggest you spend a long time to make a survey among the most popular open-source calculators and check how they implement the exact issue and they make the careful discussion between developers.
This issue should be considered SERIOUSLY. Because when the class of exactmat is defined. Both developers and users would be affected by the versions after it. If you try to do it whatever. Re-construction after the matrix library is expanded to large size would not only be the nightmare of developers, the speed of calculation issues would make the prospective users feel this project less attractive.

For the readme part, I suggest you write a tutorial on how to revise the library and where to write the tests and how to run the test. Spending hours on figuring out how to do the things above would probably make people who have higher math ability than coding ability give up the contribution because the study cost of running test is too much, way much more than studying the grammar of typescript.

Additionally, you can call me Haise instead of my full user name.

@Haise-Turquoise
Copy link
Author

Here is the interface of the exact mode of matrix calculation by Wolfram Alpha

wolfram2
wolfram1

@Haise-Turquoise Haise-Turquoise changed the title Exact Mode for matrix library file (matrix.ts) EXACT MODE for matrix library file <matrix.ts> Jul 21, 2020
@Haise-Turquoise Haise-Turquoise changed the title EXACT MODE for matrix library file <matrix.ts> EXACT MODE for matrix library <matrix.ts> Jul 21, 2020
@AGDholo AGDholo added enhancement New feature or request help wanted Extra attention is needed labels Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants