Μετρικός υπολογισμός

Genius implements modular arithmetic. To use it you just add "mod <integer>" after the expression. Example: 2^(5!) * 3^(6!) mod 5 It could be possible to do modular arithmetic by computing with integers and then modding in the end with the % operator, which simply gives the remainder, but that may be time consuming if not impossible when working with larger numbers. For example, 10^(10^10) % 6 will simply not work (the exponent will be too large), while 10^(10^10) mod 6 is instantaneous. The first expression first tries to compute the integer 10^(10^10) and then find remainder after division by 6, while the second expression evaluates everything modulo 6 to begin with.

The inverses of numbers mod some integer are computed by writing them as rational numbers (as long as the desired inverse exists, of course). Examples:

10^-1 mod 101
1/10 mod 101

Modular evaluation also works with matrices including taking inverses, powers, and dividing. Example:

A = [1,2;3,4]
B = A^-1 mod 5
A*B mod 5

This should yield the identity matrix as B will be the inverse of A mod 5.

Some functions such as sqrt or log work in a different way when in modulo mode. These will then work like their discrete versions working within the ring of integers you selected. For example:

genius> sqrt(4) mod 7
=
[2, 5]
genius> 2*2 mod 7
= 4

sqrt will actually return all the possible square roots.

Μην συνδέετε τελεστές mod, απλά τοποθετήστε τους στο τέλος του υπολογισμού, όλοι οι υπολογισμοί στην παράσταση στα αριστερά θα εκτελεστούν σε αριθμητική mod. Αν βάλετε μια mod μέσα σε μια mod, θα πάρετε απροσδόκητα αποτελέσματα. Αν θέλετε απλά να πάρετε υπόλοιπο ενός απλού αριθμού και να ελέγξετε ακριβώς πότε παίρνονται υπόλοιπα, καλύτερα να χρησιμοποιήσετε τον τελεστή %. Όταν χρειάζεται να συνδέσετε αρκετές παραστάσεις σε αριθμητική υπολοίπων με διαφορετικούς διαιρέτες, μπορεί να είναι καλύτερο να χωρίσετε απλά την παράσταση σε αρκετές και να χρησιμοποιήσετε προσωρινές μεταβλητές για να αποφύγετε ένα mod μέσα σε ένα mod.