![]() |
[QUOTE=xilman;496283]Try writing down the equations and mathematical manipulations as you read through the explanations. Insert the "simple" intermediate steps which I omitted for brevity.
The first advice helps fix the notations and processes in your memory. The second ensures that you understand what is going on rather than just taking it for granted that you do. These techniques, of course, apply equally well to most mathematical explanations. Professional mathematicians use them all the time to understand papers written by others.[/QUOTE] Ok... I've tried working this out while also reading the Wikipedia article on the Diffie-Hellman key exchange... :unsure: So we have two parties, Alice and Bob. They publicly agree to use 23 (must be prime) as a modulus and 5 as a base. Each then has their secret exponent; Alice chooses 4, and Bob chooses 3. Then, Alice computes [$]5^4 \ \text{mod} \ 23 = 4[/$] and publicly displays the result. Bob does the same with [$]5^4 \ \text{mod} \ 23 = 10[/$] Now Alice uses Bob's result as her base, giving her [$]10^4 \ \text{mod} \ 23 = 18[/$], and Bob gets [$]4^3 \ \text{mod} \ 23 = 18[/$]. Both the final result and the exponents are known only to them, because they have not been shown publicly. They know that they have the same answer, because: [$$]\text{Alice's result}^{\text{Bob's secret number}} \ \text{mod} \ 23 = 5^{\text{Bob's secret number} \ * \ \text{Alice's secret number}} \ \text{mod} \ 23 = \text{Bob's result}^{\text{Alice's secret number}} \ \text{mod} \ 23[/$$]Which alternatively looks like: [$$](5^{\text{Alice's secret number}} \ \text{mod} \ 23)^{\text{Bob's secret number}} \ \text{mod} \ 23 = (5^{\text{Bob's secret number}} \ \text{mod} \ 23)^{\text{Alice's secret number}} \ \text{mod} \ 23[/$$] I'm not quite sure how this works. I think that the order of exponents is commutative, since [$](a^b)^c = a^{bc}[/$], but the modulo operation in the parentheses is weird. Is that the logic behind how the equality works? And I'm not particularly sure where your steps align with mine; is [I]K[/I] in this case 18? |
[QUOTE=jvang;496403]but the modulo operation in the parentheses is weird.[/QUOTE]
If you think about this as happening over the integers, the inner modulo doesn't matter - it says express the parenthetical expression as 23x+k and keep k. The outer expression says express k^c as 23x+j and keep j. But the binomial expansion of (23x+k)^c will have terms divisible by 23x except the k^c term, so it will result in the same j value. Alternatively, you can think of this as happening over a field of 23 integers (0 to 22). In this form, the "mod 23" isn't an extra operation, it is a modifier that says the multiplication is happening in this field instead of over the integers. In this form it looks like (a^b)^c, but the multiplication doesn't mean the same thing anymore (although it behaves so much like the old that it makes sense to keep the notation). |
[QUOTE=wblipp;496412]If you think about this as happening over the integers, the inner modulo doesn't matter - it says express the parenthetical expression as 23x+k and keep k. The outer expression says express k^c as 23x+j and keep j. But the binomial expansion of (23x+k)^c will have terms divisible by 23x except the k^c term, so it will result in the same j value.
Alternatively, you can think of this as happening over a field of 23 integers (0 to 22). In this form, the "mod 23" isn't an extra operation, it is a modifier that says the multiplication is happening in this field instead of over the integers. In this form it looks like (a^b)^c, but the multiplication doesn't mean the same thing anymore (although it behaves so much like the old that it makes sense to keep the notation).[/QUOTE] From my limited readings in number theory I [I]think[/I] that I have a basic idea of what a "field" is; is that a group of integers that fulfill a property? Or those which are closed in the basic arithmetic operations...? If so, I might get the gist of what you're saying :unsure: |
I was talking with my dad about atoms and stuff, and apparently he didn’t know that an atom's nucleus is very small by volume compared to the volume that the atom occupies. So here’s a brief history on atoms:
The original idea of an atom was conceived by Democritus, an Ancient Greek philosopher. He thought that matter was composed of indivisible units with unique properties, termed “atomos.” This was only a philosophical idea, not rooted in evidence and experimentation. Thus, Democritus was not only incorrect in how he thought atoms looked and behaved, but was also unable to convince others of his idea. Fast forward 2000 years to the early 1800s, when John Dalton was investigating what we now know as the law of multiple proportions. This states that elements in a reaction always react in ratios of (relatively) small whole numbers, such as 1H + 2O = 1H2O. This means that 1 unit of hydrogen plus 2 units of oxygen results in 1 unit of water. “Unit” can be replaced with gram, mole, atoms, etc. Dalton proposed the concept of atoms to explain this phenomenon. Soon afterwards, Robert Brown observed the movement of dust grains in water with a microscope. He found that their motion was erratic, which is now known as Brownian motion. Random molecular motion of the water molecules was suspected to cause this, which was later proved by Albert Einstein. Then another physicist, Jean Perrin, used the work of Einstein to prove Dalton’s atomic theory, determining the mass and dimensions of atoms. Next came the discovery of electrons by J. J. Thomson, who measured the mass of particles in cathode rays. These particles were found to be the same as those carrying electrical currents and negative charge in atoms. This conflicted with the idea that atoms were indivisible. However, Thomson thought that electrons were distributed inside an atom in a uniform sea of positive charge, known as the plum pudding model. This was later shown to be incorrect. The discovery that refuted the plum pudding model was by Hans Geiger, Ernest Marsden, and Ernest Rutherford. They bombarded gold foil with alpha particles (the helium atom ejected from a larger nucleus during radioactive alpha decay). The expected outcome was for the alpha particles to pass straight through the foil with very few deflection, since alpha particles had a relatively high momentum that would not be affected by the theorized uniform field. Most of the particles exhibited this behavior, but some bounced at extreme angles. This led to the discovery of the nucleus, which Rutherford postulated to contain the atom’s positive charge and most of its mass. The model to describe this new idea came from Niels Bohr, who proposed the electron orbital (or planetary) model. Electrons followed specific orbits and could only switch between them with the addition or subtraction of energy from the system by absorption or radiation of a photon. This helped to explain the stability of electrons in their atoms and the absorption and emission of electromagnetic radiation by elements. The Bohr model is still taught in schools today, despite having been superseded by the electron cloud model. The main difference is that electrons in an atom are not strictly confined to their orbitals and inhabit tiered regions of space rather than strictly defined orbital levels. Some even more recent developments have shown that some sopubatomic particles are not indivisible, namely protons and neutrons. These are made up of even smaller particles, called quarks. These are not known be be further divisible, and are known as elementary particles. There are several other elementary particles, including electrons. The existence of quarks explains why protons have different masses; a proton is 1836 times the mass of an electron, and a neutron is 1839 times the mass of an electron. This is because each is composed of different types of quarks. Protons have 2 up quarks (+2/3 charge) and 1 down quark (-1/3 charge), while neutrons have 2 down quarks and 1 up quark. Last bit of neat stuff: the nucleus of an atom has a radius of between 1 and 7 femtometers, while the atom’s radius is on the order of 10^5 femtometers! :jvang: |
The Wikipedia article on atoms has some neat facts:
[QUOTE]Atoms form about 4% of the total energy density of the observable Universe, with an average density of about 0.25 atoms/m^3. Within a galaxy such as the Milky Way, atoms have a much higher concentration, with the density of matter in the interstellar medium ranging from 10^5 to 10^9 atoms/m^3. The Sun is believed to be inside the Local Bubble, a region of highly ionized gas, so the density in the solar neighborhood is only about 10^3 atoms/m^3.... Up to 95% of the Milky Way's atoms are concentrated inside stars and the total mass of atoms forms about 10% of the mass of the galaxy. (The remainder of the mass is an unknown dark matter.)[/QUOTE] |
[url]https://education.jlab.org/qa/how-much-of-an-atom-is-empty-space.html[/url]
[QUOTE]Put another way, if a hydrogen atom were the size of the earth, the proton at its center would be about 200 meters (600 feet) across.[/QUOTE]How big would the electron be? :mike: |
[QUOTE=Xyzzy;496739][url]https://education.jlab.org/qa/how-much-of-an-atom-is-empty-space.html[/url]
How big would the electron be? :mike:[/QUOTE]Good question. The answer is that no-one knows, but it is small. |
If we assumed that each particle could be represented by solid spheres of uniform density and that they were of equal density, then we might be able to approximate that scenario? Although I'm not sure what kind of ratio we could use for that, though we do know that a proton is 1836 times more massive than an electron :whee:
Did a bit of Haskell today, mostly learning about [C]words[/C] and [C]unwords[/C]. I feel like I've used them before, but I think I forgot about them. They sure make a lot of kata pretty easy, like [URL="https://www.codewars.com/kata/stop-gninnips-my-sdrow/"]Stop gninnipS My sdroW![/URL]: [CODE]module Codewars.Kata.Spinning where spinWords :: String -> String spinWords str = unwords [if length x > 4 then reverse x else x | x <- words str] --spinWords str = unwords (map (\x -> if length x > 4 then reverse x else x) (words str))[/CODE] After I made the list comprehension I tried using [C]map[\C], which also worked. After I submitted the code I looked at the top submission; pointfree form looks so satisfying! I'm getting the hang of some of it, but more complicated pointfree code is really weird to read. I looked through the other submissions, and only found one that didn't use [C]words[/C]/[C]unwords[/C]. They instead used [C]splitAt[/C] and [C]intercalate[/C], which ended up doing the same thing. |
[url]https://www.iflscience.com/space/you-could-fit-the-entire-human-race-into-a-sugar-cube-and-13-other-facts-to-put-the-universe-into-perspective/[/url]
:ouch2: |
I came across a really neat solution to a level 7 kata, [URL="www.codewars.com/kata/number-climber/"]Number climber[/URL], that stumped me a while back:
[CODE]module Codewars.NumberClimber where climb :: Int -> [Int] climb = reverse . takeWhile (>=1) . iterate (`div` 2)[/CODE] I get how the program works, but now I'm really interested in how laziness works. How does Haskell know that the infinite list has no more values equal to or larger than 1 in it? I expected this level 6 kata, [URL="https://www.codewars.com/kata/are-they-the-same/"]Are they the "same"?[/URL], to be harder, but it was pretty straightforward. [CODE]module Codewars.Kata.Compare where import Data.List comp :: [Integer] -> [Integer] -> Bool comp xs ys = if (sort (map (^2) xs)) == (sort ys) then True else False[/CODE] However, no other solutions I saw used anything different; they all squared the elements of the first list and compared that to the second, which seems inefficient for large numbers and/or for large lists. I can't think of a better way to do so... Earlier in the thread I had trouble with [URL="https://www.codewars.com/kata/delete-occurrences-of-an-element-if-it-occurs-more-than-n-times/"]Delete occurrences of an element if it occurs more than n times[/URL]. Adding a couple bits of code fixed what I had: [CODE]module Codewars.Kata.Deletion where import Data.List deleteNth :: [Int] -> Int -> [Int] deleteNth lst n = reverse (reverse lst \\ (concatMap (drop n) (group (sort lst))))[/CODE] [C]\\[/C] is a new operator I learned about. It removes all occurrences of elements that are in the second list from the first. The code to the right of [C]\\[/C] is a sorted version of the input minus n occurrences of each element. The original list to be operated upon needs to be reversed, since we need to keep the order and [C]\\[/C] deletes from the right. Seems like a pretty useful function/operator! |
[QUOTE=jvang;496941]How does Haskell know that the infinite list has no more values equal to or larger than 1 in it?[/QUOTE]
It doesn't need to know that: the takeWhile stops at the first zero in the list. [QUOTE=jvang;496941] [CODE]module Codewars.Kata.Compare where import Data.List comp :: [Integer] -> [Integer] -> Bool comp xs ys = if (sort (map (^2) xs)) == (sort ys) then True else False[/CODE][/QUOTE] Yes, that works, and the final line can be made even simpler: [CODE] comp xs ys = (sort (map (^2) xs)) == (sort ys) [/CODE] |
| All times are UTC. The time now is 10:06. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.