/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/ /* [ Created with wxMaxima version 0.8.4 ] */ /* [wxMaxima: input start ] */ /* Short manual for using this file with the software tool Maxima: Execute a command by selecting and entering shift-Enter. Assign values to variables by : ; Variables need not be declared explicitly. They may be used in all commands after a value has been assigned. The value last assigned is the current one. All commands are executed in the order they are selected by hand (multiple selection in a row is possible). It does not matter in which order they are placed in the file. You may always edit, change or execute a given command. This is treated like a new command. New commands may be inserted at any time at any place (just select the position). The position of a command, however, does not matter for execution. Only the order of execution matters. More explanations are given via the help menu or tutorials in the internet. "Command" like this one which only contain a comment need not be executed. However, execution does not harm as long as you do not mind the incorrect syntax error message. */; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* enables measuring the execution time of commands */ showtime:true; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Some notes for the cryptographic method RSA (for interested readers): RSA is a private-public-key method which encrypts a message using a big RSA number. This RSA number must be the product of two big primes. Encryption and decryption are performed with modular arothmetic functions where the RSA number is the public modulus. One of the two cryptographic functions uses a public number, the other one a private number. Depending on which is the private and which is the public number, you may either transmit messages which can be read by a certain receiver only or you may check signatures which could only be produced by a certain sender. The encrypted message is safe against unauthorised decryption, as long as the factors of the RSA number remain secret. Otherwise, it is easy to decrypt a message, because the general RSA method is known to everyone (see wikipedia). Remark: RSA has got some weak points. In modern cryptography, even safer methods are applied. */ /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* the largest RSA number known in public, is considered very safe against factorisation attempts */ rsa2048: 25195908475657893494027183240048398571429282126204032027777137836043662020707595556264018525880784406918290641249515082189298559149176184502808489120072844992687392807287776735971418347270261896375014971824691165077613379859095700097330459748808428401797429100642458691817195118746121515172654632282216869987549182422433637259085141865462043576798423387184774447920739934236584823824281198163815010674810451660377306056201619676256133844143603833904414952634432190114657544454178424020924616515723350778707749817125772467962926386356373289912154831438167899885040445364023527381951378636564391212010397122822120720357; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* checks if it is a prime number: */ primep(rsa2048); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* factors a number: (Warning: This may take a little longer ... If you are successful, enrol at an intelligence service of your choice!) */ factor(rsa2048); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ n1: 68547645316547382384; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ n1: 6854764531654738238477584303485647309342; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ n2: 25374892834657634858; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ n2: 2537489283465763485875437263475634728348; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* next prime greater than n1 */ p1: next_prime(n1); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ p2: next_prime(n2); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ myRSA: p1 * p2; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ primep(myRSA); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* If there are no small factors, the factorisation of not that big numers already takes long: */ factor(myRSA); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ factor(n1); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ factor(n2); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Definition of an own function: Before using the first time, just execute this once by shift-Enter: */ primesLessThan(n):= block( [p,result], /* local variables */ p:2, result: [], while p <= n do (result: cons (p, result), p: next_prime(p)), reverse(result)); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Here you may determine the parameter for prime numbers: You should work with several values for n. */ n: 1000; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Determine all prime numbers less than n: */ primes: primesLessThan (n); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* quantity of numbers in primes: */ length (primes); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Explanation of the next command (if you are interested, otherwise just execute!): Here 2 commands are executed at once (separated by ;). % yields the value of the command of previous execution, numer gives the numerical representation of that value. The logarithm is always considered for base e, in Maxima represented by %e (analogous constant definitions: %pi, %i) */; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* logarithmic estimate for density of prime numbers: If you do not add "%,numer", the result would not be evaluated numerically but rather given in exact notation. */ n / log(n); %, numer; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* Here you may assign a new prime to p1: Just replace 123456789 by a different number */ p1: next_prime(123456789); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ p1successor: next_prime(p1); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ p1successor - p1; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ /* The next number yields the average distance from p1 to its successor (each ln (p1)-th number is a prime on average) Compare the the difference above */ log(p1), numer; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ log(%e), numer; /* [wxMaxima: input end ] */ /* Maxima can't load/batch files which end with a comment! */ "Created with wxMaxima"$