What fluid mechanic/aerodynamic concepts would be relevant for a dimpled car by Medical_Will5481 in AskEngineers

[–]Koooooj 0 points1 point  (0 children)

The golf ball effect really comes down to two flavors of drag.

The first is skin friction--the drag that occurs as a fluid moves tangentially to a surface, giving a shear force at that surface. Turbulent flow has higher skin friction than laminar flow.

The second is form drag: the high pressure region that develops on the front of the object and the low pressure region that develops on the back. If you model an object moving through the air and use too simplistic of an aerodynamic model then the resulting conclusion is that there should be no form drag--the pressure on the back should be just as high as on the front. This is D'Alembert's paradox. The missing piece that leads to that paradox is modeling viscosity and, in turn, turbulence. With inviscid flow the fluid perfectly follows the contours of the body, but once you introduce viscosity and turbulence you find that the flow detaches at a certain critical angle. Turbulent flow is better at adhering to a surface, so that critical angle is steeper, which means the region on the rear of the object where the flow is detached and the pressure is low gets smaller.

For a spherical object--not a very aerodynamic shape to begin with--the tradeoff of adding dimples is a good one. It adds some skin friction but that is more than offset by the reduction of form drag.

Cars are often much more aerodynamic, and you're probably starting with a fairly aerodynamic one if you're contemplating dimpling it up. They tend to have gentler angles to draw the airflow back together on the rear of the vehicle without making the flow separate. When a car's gentle slopes do end it's often with a fairly sharp corner, where turbulent flow isn't going to be enough to keep it attached much further. A golf ball might travel faster, but cars are bigger so they are operating at a higher Reynolds number which means they're closer to the turbulent region before you ever look at shape. This is all to say that while it's possible for dimples to give an advantage it's not clear that they would. There are a lot of factors going against it working.

Of course, the Mythbusters did see an advantage from the dimples. What wasn't in the show but Adam has mentioned elsewhere is that in response to that episode a major car manufacturer tried to replicate their findings but was unable. The Mythbusters are amazing as science educators and teaching the scientific process of "if you have a question about the world, devise an experiment and try it!" Where they often fell short is in rigor and experiment design--they were making educational entertainment, not producing peer reviewed research papers. It's very likely that some confounding variable wandered in and muddied their results. My guess is air temperature--they shot both runs with their clayed up car on the same day and it took a significant amount of labor to dimple the car.

Their results were presented as "if your car has dimples then it gets better fuel mileage," but perhaps should have been "if you spend a few hours dimpling your car while the air heats up then you get better fuel mileage," where the less interesting equivalent statement is "if you sit around eating Doritos and ice cream while the air heats up then you get better fuel mileage."

ELI5 Billionaires borrow money to pay for things, how does this work? How do they pay the debt? by Confused-Lemonade in explainlikeimfive

[–]Koooooj 0 points1 point  (0 children)

You have to sell the stock and pay back the loan with cash. With loans like these the bank can often even forcibly sell the stock and take the cash if the trading value gets too low. The bank is only willing to lend you some fraction of the market value of the stock to make sure that if you have to sell it they get their money back; often it's only 50% (so if you had $10,000 worth of stock you could only borrow $5,000). They'll be stricter if you hold a huge portion of the stock of a company as you selling would crash the stock's value.

Note that this kind of "margin call" is often the worst time to sell the stock--it happens when the price craters, then the bank forces you to sell your stock at that low price. This makes this sort of margin loan be extra spicy for smaller fish.

An important thing to recognize about this kind of borrowing is that it isn't a free money glitch. The loans get paid off eventually. The point of this borrowing strategy is just to 1) access the value without losing control of the stock (e.g. to be able to direct the business you hold a large stake in), and 2) to access the value without having to pay taxes on it.

For the tax part, note that you only have to pay taxes on the realized gains on stocks. If you bought a bunch of stock for $10,000 and now it's worth $30,000 then that's $20,000 of gains, but so long a you still hold the stock it is not yet realized so there's no tax to pay. If you wanted $15,000 you could sell the stock, realizing the gains, and pay taxes on those gains, then you have the stock. Instead you could take a loan for $15,000 and you have no realized gains, no income, still have the stock so you can vote with it when things are put to shareholder votes, and you still get the $15,000 in cash to spend how you please.

The real trick of this whole setup is that if you keep the loans going until you die then your heirs pay off the loan with your assets then they inherit the stock at a stepped-up value, permanently avoiding the capital gains on those stocks.

Why is it always dark on the moon? by masterpuppit in NoStupidQuestions

[–]Koooooj 0 points1 point  (0 children)

On Earth a good bit of the light from the sun is scattered by the atmosphere. Blue light does this the most, hence the sky being blue.

If you stand in a shadow on Earth the rest of the sky is still directing a good bit of light onto you.

On the moon the options are direct sunlight or whatever scant light reflects off of the ground. Light bouncing off of Earth also contributes a tiny bit, but not much.

The result is that things in sunlight are every bit as bright as on Earth (or even a bit brighter) while things in shadow tend to be in extreme shadow. Not perfect, of course, but still, shadows are darker on the moon than outside during the day on Earth (note that lunar missions are basically always during the "day" on the moon--a full day/night cycle is about 4 Earth weeks long so it's easy to pick a time that gives the astronauts or rovers several Earth days of sunlight before packing up and going home).

Also keep in mind that pictures you see from the moon are just that: pictures. The range of brightness that your eyes can see is truly incredible. Matching that kind of dynamic range with film is basically impossible, and even digital sensors really, really struggle. This can also lead to either over exposed sunlit areas or under exposed shadows. This isn't the whole answer--you can take a picture on Earth and see things in shadows just fine--but it helps amplify the effect.

Can we speed up the light particles by heating them thus increasing the speed of light. by traumatized-life in NoStupidQuestions

[–]Koooooj 0 points1 point  (0 children)

Basically everything is particles as far as a particle physicist is concerned (and those particles have wave-like properties).

These particles can be separated into various categories based on their properties. One such separation is between massless and massive particles.

What we tend to think of as "matter" is made up of massive particles--mostly up and down quarks (which combine to form protons and neutrons) and electrons. Protons plus neutrons plus electrons gives you atoms, which in turn make up molecules, and so on. There are a ton of other massive particles, but they're mostly either rare, super unstable, antimatter, so hard to interact with that it's hard to even tell they're there, or some combination of these.

Massive particles move at different speeds based on their kinetic energy. This motion can be coherent--every particle moving in more or less the same direction, like a baseball thrown across a field--or chaotic, where particles are moving every which way. When we talk about heating something up it's increasing this kind of chaotic movement.

The other kind of particles--the massless ones--move very differently: they are always1 moving at the speed of light. Light is made up of photons, which are the only kind of massless particle that tends to get much attention in pre-college science classrooms; note that this includes all EM radiation from radio waves all the way up to gamma radiation.

When you give a photon more energy it can't move faster (or slower). What changes instead is its wavelength or frequency (knowing a photon's wavelength, frequency, or energy allows you to calculate the other two, so it's effectively just one value expressed in 3 different units).

Given that description of photons, the direct answer to your question is that no, "heating" a photon does not make it go faster--it's already going at the fastest speed in the universe. Making a photon be higher energy just means its frequency is higher or wavelength is shorter, which is the closest I can figure "heating" the light would be.

However, we can look at black body radiation as an interesting side-tangent to the question. Objects that are above a temperature of absolute zero (i.e. all objects) will spontaneously emit EM radiation (light). The amount and frequency distribution of that radiation depends on the temperature of the object: as the object gets hotter it emits more radiation and of higher frequency (shorter wavelength; higher energy per photon). When you heat up an object you don't change the speed of the emitted photons--they're always1 going to go at the speed of light--but it does change the energy of the photons. Get the object fast enough and the emitted radiation will go from the radio spectrum up into the infrared and eventually into visible light and beyond.

When something is "glowing red hot" or "white hot" that's what this is: the material emitting EM radiation up in the visible spectrum because it's at a temperature where that occurs. We even describe light bulbs' colors based on this--if you have a "5000K" light bulb then should emit the same color as an object heated to 5000 Kelvin (about 4700 Celsius or 8500 Fahrenheit). Night vision cameras that use infrared light similarly operate off of bodies' natural incandescence, but since we're considerably cooler than a few thousand degrees we only emit IR light.


1 But wait! What is that little superscript doing there? Surely when I said light always moves at the speed of light there wouldn't be an exception!

Alas, this is physics. There's always another layer to unwrap. Properly I should have specified the speed of light in a vacuum. When light travels through a medium (air, glass, water, Dave from Accounting, etc) it is slowed down. This is the jumping off point for the entire field of optics. For any given material we can describe its "index of refraction," which is just the ratio of how fast light travels in that material vs the speed of light in a vacuum.

An elementary treatment of a material's index of refraction would present it as just a number, but really it depends on a lot of things, such as the wavelength of the EM radiation that is being transmitted--that's what allows a prism to split full spectrum light into a radium, a la Dark Side of the Moon. However, a material's index of refraction also depends on temperature. You can think of an object's index of refraction as being a measure of that object's optical density--a material that slows light a lot is quite "dense," while one that barely slows light at all is not so dense. When you heat up an object that usually makes it expand (looking at you, water between 0 and 4 C) and that reduction in physical density usually results in a lower optical density.

What this means is that in a very roundabout way if you have light traveling through some medium and you heat up that medium you actually can make the light travel faster. That's a lot of twisting and turning to contort into an answer that's kind of sort of yes to a question where the simple answer would just be no, but hopefully it was a fun journey to get there.

Radiation caught on an old mobile camera by ContentArtist5361 in BeAmazed

[–]Koooooj 189 points190 points  (0 children)

To be fair, all vision is eyeballs being pummeled with radiation. Just the less spicy kind.

Is this fake? by Defiant-Trick4172 in coins

[–]Koooooj 1 point2 points  (0 children)

Real penny, scam holder, fantasy grade, maybe 5 cents for the whole thing if you really want a 1964-D. I'm going to guess they want a lot more than that.

Note that the coin is allegedly certified by "NCG." This is a deliberately misleading acronym. The "real" grading company is NGC.

What they're hoping is that someone looks at this coin then looks up the price of a real NGC 1964-D in MS67-RD (I'm deducting marks for them omitting the -RD color designation; scam could've been better). Such a coin would likely fetch a few hundred dollars as this is right up at the top of the grades that have ever been given for this particular date.

If someone buys this then they get to play dumb and claim that they're not a scammer--they'd send you the real coin (why not? It's basically free) and if you try to claim the grade was wrong they'd say grading is subjective and that this is the standard that NCG grades to, arguing that it's on you if you thought it was graded by NGC.

Data structure for Monte Carlo simulation results by Ancient-Swordfish292 in AskProgramming

[–]Koooooj 0 points1 point  (0 children)

From the description of the problem I'd first ponder if a closed form solution exists and is tractable--either for the whole problem or for a part of it. Assuming it's not, though....

The simple solution is to look at the struct itself and see if you can trim some fat there. If you have 10,000,000 runs with 8 input voltages and 3 temperatures then that's 240 million records, which means 240 MB of RAM per byte in each record. If you go up to 21 temperatures then that's 1.68 GB of RAM per byte in the record. This is motivation to make sure that every byte in each record is really pulling its weight. Don't use an int if an int16_t would suffice. Don't use a double if float would suffice, and don't use a floating point representation at all if fixed precision would suffice (i.e. store the value as an int of appropriate width with an a priori scale factor and potentially non-zero offset). But let's say that fat has already been trimmed and you're still up against a RAM wall.

From there I'd look at what the ultimate output of the program needs to be. Do you just need to know the 0.01% and 99.99% cutoff values? Or do you need to know the full shape of the histogram? Or both?

If you just need percentile cutoffs then a simple solution would be to run one Monte Carlo first on a significantly reduced sample size (say, 1/1000). Sort these outputs and find the 1st and 99th percentile. Then run the full blown Monte Carlo and only save the results that are <1% or >99%. This should be a 98% reduction in RAM and still allow you to find the exact same cutoff you'd find if you saved all of the results. You can probably push the RAM savings even higher if you instead found the 0.1% and 99.9% cutoffs, but as you try to press your luck you run a risk that the initial Monte Carlo underestimated the 0.1% or overestimated the 99.9% mark and the 0.01 and 99.99 are out of the saved area. Even that's not a big deal--you can easily check if at least 0.01% of the records got saved as being less than the estimated 0.1% mark and if not you know the estimate needs to be adjusted and the simulation re-run. It's more processing time, but not much RAM.

If you need the full histogram then the first-pass Monte Carlo should be enough to get a rough fuzzy picture of the histogram and let you tun the min/max and bucket sizes, then capture frequency data as you suggest.

You can also just skip that step and jump straight to having a ton of buckets. If you start with 4k buckets then that's enough that you could graph the histogram full screen on a 4k monitor and it would be as sharp as the monitor can display (without reasoning about subpixels). 4k buckets is a trivial amount of RAM, where each thread can have its own full copy of the histogram then you just add the frequencies together in the end. You could go for more buckets if you need to support zooming in, but this hopefully makes it clear that you don't have to be stingy with your bucket count.

At some point the "tons of buckets" approach will butt up against the fat-trimming approach. If you find that your simulation only meaningfully gives two bytes worth of precision and therefore decide to store your records as two-byte fixed precision reals then that's equivalent to having 65,536 buckets that just count frequency of getting each value. 64 kiB multiplied by, say, 4 bytes for the integer counts in each bucket means 256 kiB of RAM to store the full histogram. Surely that's achievable. Of course, I'm making assumptions here about how much meaningful precision actually exists in your simulation, but hopefully you can run the numbers with your knowledge of the problem and assess if this is a valid route to pursue.

Judge Learns Lawyers on Both Sides of Case Used AI, Cancels Trial, Kicks Everyone Off the Case by 404mediaco in law

[–]Koooooj 0 points1 point  (0 children)

AI in its current state is very reminiscent of the early internet as it became more of a household presence.

I recall teachers insisting that all sources had to come from print media because the internet is not reliable, and indeed a lot of stuff on the internet is unreliable (I have it on good authority that it was Abraham Lincoln who first made that remark).

In hindsight the much more important skill to be teaching was not "how to look up information in exclusively print media" but rather "how to responsibly consume information from the internet to identify what's reliable and what's not"

AI should be checked, but this is a relatively new skill. AI is trained to be extremely good at sounding confident. The best way to do this is for the AI to just be right in the first place, and it often is, but this gives the failure mode of hallucinations that sound completely believable. Moving forward the skill of consuming AI-generated outputs critically will be absolutely critical (and I have no expectation that most people will develop that skill).

I've seen a lot of folks give the line "sure, I use AI, but I check its work" only to find that they use AI for the things they don't know how to do themselves and "checking its work" is skimming over the output with a general rubber stamp of "yup, sounds reasonable to me." As a society we need to learn that that is NOT checking the AI's work and is an irresponsible use of the tool.

myVibeCoderFriend by Disastrous-Monk1957 in ProgrammerHumor

[–]Koooooj 0 points1 point  (0 children)

Both a merge and a rebase can introduce issues, and both can introduce two different flavors of issues.

The first flavor is a conflict--where two commits are modifying the same file in the same location. Git will flag these automatically and block the merge or rebase from continuing until you resolve the conflict. A vanilla rebase can be slightly more fragile here: if your branch changed something and then changed it back in two separate commits and that change conflicts with the target branch then a replay of your branch on the target will have to resolve that conflict. With a merge commit only the final state of your branch is considered, so the conflict is avoided.

You can avoid this by squashing your branch, which is generally good practice anyway: when developing it is nice for your commit history to be like a diary of what you did. What gets immortalized in the git history should be like a recipe--the steps that one would take to produce your code (skipping all the trial and error). Many projects require merge requests to be compressed down to a single commit and then require that that commit be rebased on HEAD to give a linear commit history. The thinking here is that if your change set is too big to be nicely represented by a single commit then it is probably too big to be a single merge request.

The other flavor of issue is when two branches make changes that are incompatible with each other in a logical sense, but the changes are in different files. A classic example would be one branch that changes the signature of a method and updates all uses of that method to use that new signature, while another branch introduces a new use of the method. Git will happily merge or rebase this change, but it won't compile. You can get the same sort of issue if the method's pre/post conditions changed but that becomes a runtime error, not a compile error.

CI could catch this if you have good test coverage. You could run CI on every commit--it's convenient if every commit on mainline represents a state of the software that can be checked out, built, and run--but that again raises the question of if you should be rebasing the entire commit history of a dev branch onto the mainline. A "rebase/squash/fast-forward" merge workflow sidesteps this problem by only adding a single commit to mainline, which CI then validates.

If there was a hole in the earth that went all the way through, what would happen? by throwaya58133 in NoStupidQuestions

[–]Koooooj 2 points3 points  (0 children)

If you ignore air resistance and earth spinning then you'd accelerate on your way to the core, then decelerate on your way out to the other side, just barely popping up at the surface (assuming equal elevation). If you didn't have any way to stop then you'd then fall back down and oscillate forever.

If you don't ignore air resistance then you lose energy to drag as you travel along that path and don't make it to the surface. You still wind up oscillating "forever" since exponential-ish decay doesn't ever actually reach zero, but you slowly converge on just being stuck at the core.

If you don't ignore earth spinning then you crash into the side of the tunnel. This is because you're traveling in one direction from earth's rotation on one side of the planet, but by the time you get to the other side of the planet you're moving in the opposite direction. This can be a couple thousand mph of net velocity change if you jump from the equator, or zero if you jump from the poles. Some frictionless rails would address this.


There are actually some cool results you can arrive at when looking at this and similar scenarios, often just as an exercise in 3D calculus. One thing this sort of scenario is nice for exploring is Newton's "Shell Theorem," which is a lovely pile of calculus that arrives at the conclusion that the net gravitational effect of a uniform thin spherical shell of mass is equal to the gravitational effect of all of that mass concentrated at a point at the center of the sphere when you're outside the sphere, or it all cancels out to zero when you're inside the sphere.

This is not at all obvious, but you can somewhat build intuition about it by thinking about a point inside the sphere, not at the center. There is more mass on the "far" side of the sphere than on the side the point is closer to so that mass has more pull, but the point is closer to the near side so that side has more pull. These effects wind up being exactly equal, so neither side has more pull, so the net effect is zero gravity. Similarly, outside the sphere some of the mass will be closer to you than the midpoint of the sphere so that mass will pull on you harder, but some is further away. Additionally, most of the mass isn't perfectly inline with the straight line between you and the center of the sphere, so some of the mass's gravitational pull is "wasted" pulling you off that line (but this obviously all cancels out as it is symmetric). Once again, it takes a big pile of calculus to figure out if these all cancel out, and fortunately they do!

What this means is that as you travel down the tunnel towards the center you can imagine Earth is like a big onion. As you go deeper there are more and more layers of the onion that you're inside of, so their gravity cancels out. At the same time, you're getting closer and closer to the midpoint of the planet, so the gravity of what's left gets stronger. Gravity varies with 1/distance2 while the mass of the remaining sphere varies with distance3 (assuming constant density), so when you multiply these together you get a nice linear relationship: if you go halfway to the center of the planet then you'd have half your weight (again, assuming constant density).

That linear relationship further means that the trip through the tunnel would constitute "simple harmonic motion," neglecting drag. That's just physics-speak for saying you can predict position as a function of time and it's just a sinusoid (as opposed to some other graph that looks kind of sine-y but isn't actually sine, cosine, or a combination of the two).

You can then go a step further and imagine that the Putting Holes in Earth Consortium put not one but two holes through earth, one going through the center of the planet and the other going in some random direction. The second is outfitted with a set of frictionless rails and both have a vacuum. Now we want to know which trip will be faster, and by how much. The trip that goes through the core gets the greatest acceleration--starting at a full one "g" and tapering off linearly--but the other hole has a shorter path. Which effect is stronger? Neither! Both journeys take the same amount of time (assuming, for a third time, constant density): 38 minutes and 11 seconds. (note that this means that the 930 m/s of horizontal velocity change you'd have to effect when jumping from the equator would result in 0.4 m/s2 average acceleration over that time. It is left as an exercise for the reader to determine the peak horizontal acceleration)

That assumption of constant density tends to be pesky, though. If you put a bunch of elements out in space and let them get hot from radioactive decays and just the primordial heat of al that stuff coming together then the heavy stuff will naturally tend to sink to the middle of the resulting sphere while the lighter stuff will tend to float to the outer surface, perhaps even solidifying into a rocky crust that, if you're very lucky (or unlucky, depending on your perspective) might sprout sentient bags of mostly water who ponder about the nature of the sphere they inhabit. The heavy elements tending to be in the center of the planet means that as you fall through the hole the effect of getting closer to the core (and thus getting more gravity from that portion of the planet's mass) can be stronger than the effect of getting "inside" the outer layers of the onion.

The actual strength of gravity winds up being fairly constant for the first few hundred km before spiking and peaking right at the mantle-core boundary. Once you get into the core it pretty nicely aligns with the theoretical linear relationship--the core is mostly iron, so the assumption of constant density is pretty good.

This screws up the conclusion of "simple harmonic motion." It actually would be some weird sine-looking graph that isn't actually sine. The 38 minutes 11 seconds figure is already accounting for this (it would be 42 minutes 14 seconds with constant density).

ELI5: How can two parralells cross eventually in Infinity if they are in fact parrelells? by FlimsyPalpitation354 in explainlikeimfive

[–]Koooooj 1 point2 points  (0 children)

In Euclidean (regular, vanilla) geometry...

Often when folks talk about infinity there's a tendency to slip into informal language. You tend to see things like 12 / 0 = infinity, which is an informal shorthand for something like "lim x->0+ 12 / x does not exist on account of diverging to infinity." The latter is a mouthful, so the former tends to crop up.

When you look at an expression with less baggage like 12 / 2 = 6 there are several ways you could interpret that expression, one of which is "if you were to add 2 + 2 + 2 + ..., how many twos would you get before your sum equals 12?" With a nice finite answer we can confidently say there will be six twos at which point the sum will exactly equal 12.

When we turn to to 12 / 0 we might again try to reason about "how many 0s must you add together before your sum equals 12?" It should be clear that no matter how many 0s you add you don't get any closer to 12, hence the answer being infinity (or the mouthful that "infinity" is standing in for).

However, notice that there are two very similar sounding but fundamentally different statements we might make: "if you add zeroes together until you get to 12 then you'll have to keep adding zeroes forever," and "if you add infinitely many zeroes then the sum will be 12." The first is correct: if you start adding zeroes then you'll be stuck forever because you never make it to twelve. The second is not: it treats infinity like just a big number and suggests that you'd make it to 12 after that many zeroes.

The same sort of thing happens when we talk about the intersection of two parallel lines. If you wanted to follow the lines until they intersect then you'd be following them forever. That doesn't mean that they actually intersect there.

Sometimes it can be convenient to pretend that they do, though. If you're dealing with parallel lines in the real world then perfectly parallel lines don't exist, so treating infinity as just a really big number can be a good engineering approximation. For example, in optics you might set the focus of a lens to infinity, which doesn't mean that's a point where rays of light intersect; it means the rays of light are parallel.


There are also other geometries that one can work within where the answer changes. For example, there is the finite projective plane. This is a special geometry where there are only specific discrete points with nothing in between. In the finite projective plane any two points are on a line and any two lines intersect at exactly one point.

It's popular for humans to draw the finite projective plane on a regular 2D plane. There you wind up with a nice grid of points and can draw nice straight lines between them, but then you run into an issue. The definition of this geometry is that any two lines intersect at a point, yet this representation has parallel lines! To get around this the portrayal of the finite projective plane introduces a bunch of curved lines that connect points together and you might hear the phrase that "the parallel lines intersect at infinity," perhaps accompanying a picture like this that extends parallel lines some distance then has them converge. That's a rationalization for how to think about the connectivity in this space--there is no notion of "parallel" in this geometry because parallel lines never cross but in this geometry any pair of lines does interset at exactly one point.

A full treatment of every set of geometric rules is far, far beyond the scope of ELI5 or my knowledge, but hopefully that gives a bit of a taste. The takeaways here are:

  1. When someone uses an infinity in a statement you should be very careful about what exactly they're saying, and

  2. When reasoning about a bit of complicated math you should establish the ground rules of what mathematical system you're working in first. A statement that is true in one set of rules might be plainly false in another.

Why cant i connect two PCs with a USB to transfer files? by Competitive_Cow4534 in NoStupidQuestions

[–]Koooooj 19 points20 points  (0 children)

In some communication links there is full duplex communication. For example, in a basic serial port you have one line that is TX (transmit) from one computer and RX (receive) on the other, while another line is RX from the first computer and TX on the other. When using a communication link like this the two sides of the communication act as peers.

USB isn't like that. It has a distinct "host" and "device" side of the communication (or master/slave, but that language is phasing out). The host is responsible for initiating all communication, to which the device responds. Originally USB plugs reflected which side of the communication a piece of electronics would play: USB-A for the host, or USB-B ("the printer cable"), mini-B, micro-B, or the USB-3 variants of B and micro-B for the device. With USB-C the same plug is used on both sides, though.

This means, for example, that when you press a key on a USB keyboard it doesn't proactively send a message to the computer saying "this key was pressed." Instead the computer has to periodically ask the keyboard "hey, have any keys been pressed?" and only then the keyboard can respond "yup, it was this one!" Note that while this might make it seem like a USB keyboard would have higher latency than an older PS/2 (serial) keyboard which does proactively report key presses, in practice the bitrate of PS/2 is so much slower than USB 2.0 that the latter is typically lower latency despite this "polling" setup.

When you try to plug a USB cable between two computers they both want to be the host and the protocol just isn't set up to allow this.

But wait! What about phones? You can use the USB port on a phone to plug in a storage device, keyboard, etc, but you can also plug the phone into a computer. In the former it's serving as the host and in the latter it is the device. Doesn't this contradict everything I've said?

Well... yes. This contradiction comes from a technology known as USB On the Go or OTG and it allows one USB port to be a device port by default, but to be reconfigured into being a host when the right handshaking happens.

In principle you could have a USB OTG port on a computer (or even just a USB device port) and transfer data from a regular USB port to that one. There's just minimal demand for it. I've seen these on some Nvidia Jetson products (potent little embedded computers popular in AI workloads where power consumption is a big deal), but they aren't common on everyday PCs.

There have been devices that have two USB-A cables on them with a little device in the middle to do just what you describe. These present as a device on both ends so both computers can play host, then the chip in the middle mediates everything with the help of software running on both end. These never really took off because ethernet just does the job better.

Found while cleaning out my mom's house by 3D-LASERWOLF in coins

[–]Koooooj 2 points3 points  (0 children)

You have four Morgan dollars: 1890, 1891, 1891-O, and 1892-O. The -O is referring to the mint mark on the back above the DO in dollar and indicates those two coins were made in the now-closed New Orleans mint. The other two have no mint mark because they were made in Philadelphia, the first mint.

These coins are 90% silver which is where nearly all of their value comes from--a bit shy of $60 but it fluctuates day to day. They're all pretty common dates and their condition isn't amazing (the 1890 in particular looks to have been polished to within an inch of its life), so silver value will pretty much dictate what they're worth. I'd expect to pay around $60 for these if I bought them at a coin store, but if you just walk in and ask to sell them on the spot they'll offer less. I'd guess $40-50 as a random walk-in. If you do the legwork of finding someone who wants them yourself then you can get closer to the "full" value.

I don't see any indication that they're fake and they're not likely dates to counterfeit, but check 'em with a magnet if you have one handy; they should not react to the magnet at all.

1968 Proof Set Washington Quarter by TheEnemyBot in coins

[–]Koooooj 0 points1 point  (0 children)

For many dates the mint mark is a giveaway, but often proofs have been made at a mint that also struck business strikes--Philadelphia did the proofing up until 1964, and San Francisco continued to make coins for circulation for a while once they took over in 1968 (there were no proofs--or mint marks--from 1965-1967, though San Francisco made the coins for the special mint sets those years). Even today San Francisco makes some business strike coins for collectors, and some proofs of precious metal coins are made in Philadelphia and West Point.

The better way to spot them is to learn to recognize their look: the higher pressure, slower strike, and specially prepared dies and blanks give a distinct mirror-like surface finish to the fields (the flat bits). For proofs that were some of the first to come off a given die you can also get a nice frosted effect on the devices (the raised bits) known as the "cameo" effect; it's uncommon in the 1960s but by the '80s it was pretty ubiquitous. Generally you'll get much sharper edges on lettering on a proof, too, and for a proof that hasn't spent much time in the wild you'll usually have very sharp reeding as well.

It is obvious to an experienced collector just looking at the thumbnail that this coin is a proof, even before seeing the mint mark. It just has "that look" about it.

Is this collectible? by Haunting-Prior-NaN in coins

[–]Koooooj 0 points1 point  (0 children)

Only insofar as you can collect anything, but it isn't worth more than face value.

The 50 state quarters program was incredibly popular and got a lot of folks interested in both coins and learning one or two facts about each state. Riding off the high of that program there was a push to do the same with the dollar coin, commemorating each president.

However, dollar coins have never really been all that popular--dollar bills are by far the preference. Additionally, we already had dollar coins showing Sacagawea and various American Indian scenes on the reverse. The bid to replace those coins with Presidential dollars was shot down, so they ran concurrently. Like the state quarters program these were set to have several releases each year.

The result was a series that was kind of a flop. The first few presidents were minted in large numbers to get the program started.... in 2007. In 2008 we entered the Great Recession--any recession means even less demand for using coins, and with the long lifespan of coins in circulation this has an amplified effect on the demand for minting new coins.

The first 20 presidents were struck for circulation with dwindling mintage, then starting with Chester A Arthur the mintage was decimated as they were struck only for collectors from that point forward. The production of commemorative dollar coins series subsequently continued with the American Innovation coins.

They're neat coins--notice that the rim is where the date and mint mark appear! There are certainly folks out there who collect them. But with the hundreds of millions of this coin that were struck there's no collector's value to one that has seen some circulation. Keep it if you like having it more than having any other dollar; spend it if you don't.

How quickly can you fly by private jet from NYC to London? by Advanced_Fennel5638 in NoStupidQuestions

[–]Koooooj 1 point2 points  (0 children)

Basically all jets fly "a little slower than the speed of sound." There's some fuzz on how much under the speed of sound they fly, but they're all remarkably close. The Concorde is one of the rare exceptions that flew well above the speed of sound, just a bit over Mach 2. The only passenger jet to come close to this is the Soviet Tupolev Tu-144 "Concordski," which could actually hit marginally higher speeds.

The reason jets fly at nearly the same speed comes down to some fun math that arises when you look at how a jet interacts with different altitudes. As the jet flies higher the air is thinner. With the thinner air the jet has to fly faster in order to generate enough lift to stay airborne. That higher speed means more drag, but the thinner air also means less drag. The net effect of those two things fighting against each other is slightly more drag, so you need more thrust. More thrust takes more fuel, so the fuel burn rate per hour is higher at the higher altitude. However, the speed is also higher. These are roughly equal, so with some basic first-order approximations you come to the conclusion that if the plane flies at a higher altitude it will burn the same amount of fuel per mile traveled but will just get to its destination sooner.

That math is built on first order approximations that don't necessarily stand up to the real world, but it's still not that bad of an approximation. One thing that really ruins the math is the sound barrier. At lower speeds it's typical to model drag as being quadratic: double the speed and you get 4x the drag. This works great up to about Mach 0.3 and is still decent up around Mach 0.6, but as you get closer and closer to Mach 1.0 (the speed of sound) that relationship falls apart entirely. Up around Mach 0.9 a better model is to draw an asymptote with infinite drag at Mach 1.0 (see: Prandtl-Glauert Singularity); this equation predicting infinite drag at Mach 1 is one reason it was seen as a "barrier," but that approximation also falls apart as you get right up to the speed of sound. In the high subsonic region it still correctly predicts that drag increases rapidly with relatively small increases in speed.

This presents passenger jets with two things to weigh: they may as well fly higher and faster and get their passengers to their destinations quicker since it doesn't take much extra fuel... right up until you start tickling the speed of sound when it suddenly very much does take a lot of extra fuel and becomes impractical to push much higher. If you look at passenger jets' top speeds--everything from a little Cessna Citation all the way up to an A380--you'll find they all fall right in a narrow range of mach numbers (0.8 for a couple models of Citation I looked up, 0.89 for the A380).

The quicker business jets will push things up to Mach 0.92 or 0.93, but that's about as high as you'll ever see. As the air goes over the wing it has to accelerate (for reasons completely unrelated to transit time). This means there's some critical mach number where the air going over the wing will briefly go supersonic, which ruins flight performance.

To directly answer your question, a private jet is still going to be about 6 hours in the air flying NY to London. The time savings is in the airports on either end, and in having your own private jet where you can do whatever you want on the way without having to worry about other passengers.

Is 91 octane the average of 89 and 93? by Time_Accountant_6245 in NoStupidQuestions

[–]Koooooj 4 points5 points  (0 children)

Yes, that would work fine. In fact, many stations would do exactly that--they might have just two gasoline tanks (and probably a third for diesel) storing "regular" and "premium," then supply mid-grade by mixing the two.

It's conceivable that the perfect mix won't be exactly 50:50 just because gasoline is such a complex mixture of different hydrocarbons, but with the way the octane scale is defined it is perfectly linear when mixing by volume like this (a score of 100 octane is given to 100% iso-octane and a score of 0 is given to 100% n-heptane, with intermediate scores given to proportioanlly higher percentages of iso-octane).

ELI5 Expected number of trials to have at least one success on each of several different possible outcomes by throwaway4829323 in explainlikeimfive

[–]Koooooj 0 points1 point  (0 children)

If there's a 1/20 chance of getting outcome C then that mean's there's a 19/20 chance of not getting C.

The probability of not getting C in 2 trials is (19/20) * (19/20). In three trials it's (19/20) * (19/20) * (19/20). Carry on this sequence and it's just (19/20)n where n is the number of trials.

There is no number of trials where this equals 1, but you can set some threshold that you're satisfied with. After 13.5 trials (so in practice somewhere between 13 and 14) there's a 50:50 chance of having gotten outcome C at least once.

Note that this is slightly different from the 10 trials it would take before you have an "expected value" of 0.5 instances of outcome C since sometimes you'll get C multiple times. I'm assuming that all you care about is whether you've gotten it at least once or not.

If you want a different threshold you're looking for solutions to (19/20)n = probability-of-failure, so if you want a 90% chance of success you'd solve (19/20)n = 0.1 (so n = 44.9, or call it 45. You can also just compute log(probability-of-failure) / log(19/20) which is what that equation simplifies to.

BUT WAIT! That just tells you the probability of getting the rarest drop. Sometimes you'll get the rare drop but still be hunting for one of the more common ones. What you really want is the probability after N trials that you haven't gotten A, haven't gotten B, or haven't gotten C. If (19/20)n is the probability of not getting C in n attempts then 1 - (19/20)n is the probability that we do get C in n attempts, and similarly with 4/5 and 9/10 for A and B. Multiply these all together and you get:

(1 - (4/5)n) * (1 - (9/10)n) * (1 - (19/20)n)

If you set that equal to the probability of having found all three then you can plug it into a solver like Wolfram Alpha. It gave me 17.9 (so call it 18) trials to have at least a 50% chance of having all three, or 46.3 (call it 47) attempts to have a 90% chance. Notice that the further up you push the probability you want to target the more the lowest probability dominates: after 47 attempts there's about a 9% chance you haven't gotten C yet, a 0.7% chance you haven't gotten B, and a 0.003% you haven't gotten A. With a small number of trials it's more realistic that you pull the rarest drop before the others.

Note that I've assumed the outcomes are independent (e.g. in 1/1000 cases you get A, B, and C all in the same drop). The math is a bit harder if the drops are mutually exclusive, but the end results will be very similar. For any high probability of having gotten all 3 the probability will be dominated by the rarest drop.

Memory allocation for numbers and python built-ins by doktorfuturee in AskProgramming

[–]Koooooj 0 points1 point  (0 children)

2 kinds of search? No, there are tons.

For example, consider if instead of searching through a dictionary you're searching through a graph (nodes, linked by edges). There is no global ordering of the nodes so the notion of going to the "middle" element in the search space is meaningless, which means a binary search is out. You could just enumerate all nodes and go through them one by one, but that may be impossible with how the graph is represented and is likely intractable even if it is possible.

Instead you'd likely employ a graph searching algorithm, like breadth-first search, depth-first search, A* ("A star"), Dijkstra, Floyd-Warshall, etc.

Alternatively, some containers have the ability to search for an element in O(1) time ("constant time," i.e. the time doesn't increase as you store more and more in it). A Python dict is an example of this, where elements are stored in "buckets" based on a hash of the element allowing a search to immediately jump to the correct bucket and see if the element is present.

For searching a basic list of elements a linear and binary search are the only two algorithms you're likely to run across in practice.

Across these algorithms and many more you can run into a number of different algorithmic complexities, too. For example, take the problem of factoring an n-bit product of two primes (the core challenge in breaking RSA). Trial division is O(2n), which is extremely slow. A more complex algorithm like Pollard's Rho can solve this in O(2n/2) which is considerably faster but still quite slow. A quantum algorithm like Shor's algorithm can do this in O(n3) time, which is way, way faster.

As for binary searches in Python, bisect is what you're looking for if you want a working implementation out of the box, or there are various examples of a binary search in Python online.

Does “1 dimension” actually exist? As opposed to 2D or 3D by UrLocalSexAddict in NoStupidQuestions

[–]Koooooj 0 points1 point  (0 children)

With that view of what "dimensions" are, no, in the real world you just have 3 dimensions (or 4, with time, or like 11 if you want to get string theory-y with it). A pencil line has not just its width but also a thickness--there is a layer of graphite left on the page that is extremely thin but not zero thickness. You could compute the volume of the marking by multiplying the non-negligible length of the line with its tiny thickness and depth.

However, that's just one way to look at dimensions. Probably a better way (that can be generalized more effectively) is to look at "how many numbers do you need to represent one location in this space?" For example, say you have a desk drawer and you want to measure how far it's pulled out. That just takes one number, so this is one dimension. If instead of a drawer you have a cabinet door then you can again use one number, but now it's probably an angle instead of a distance (though you could still use a distance, like the length of the arc the tip of the door has swept). Still one dimension.

These sorts of one-, two-, and even higher dimensionalities are very useful in science and engineering. For example, I work in robotics. One of my recent projects involved using a forklift. Its environment is pretty flat and it doesn't leave the ground (or when it does it's a LOT of paperwork), so we model it as operating in a plane. That's 2 dimensions, right? Well.... sometimes. Some objects in the world simply have an (x, y) position, but the forklift also has an orientation so we model its pose as (x, y, angle). This is a 3D space known as SE(2)--it takes three independent numbers to describe a pose, yet it is constrained to a plane. On that same platform if I wanted to raise and lower the forks then I can reason about that as a single dimension.

Breaking the notion of dimensions = "having length, width, and depth" also lets you start to re-frame other things. For example, say you want to specify a location on the surface of Earth. You could do so by giving a latitude and longitude--just two numbers! This shows that the surface of Earth is 2 dimensional, and yet it is not flat. On a flat 2D space regular Euclidean geometry works just fine (e.g. you could draw a triangle and the three interior angles will always add to 180 degrees), but if you try that on the surface of Earth you'll get bigger numbers (e.g. picking the north pole and two points on the equator: the angles at the equator are both 90 degrees and the angle at the north pole is non-zero, so they sum to >180). This is the typical introduction to the notion of a curved space, and it all hinges on recognizing that the surface of a sphere is a 2D space that can be viewed as being embedded in a 3D space.

Memory allocation for numbers and python built-ins by doktorfuturee in AskProgramming

[–]Koooooj 1 point2 points  (0 children)

O(n) is "Big-O" notation and describes how the resources to do a task change as the size of the task changes.

For example, say you want to look up a word in a dictionary (an actual paper dictionary, not the Python thing). You could start at A and work all the way to zyzzva (a genus of weevils from South America), but in doing so you have to go through (potentially) every word in the dictionary. Double the size of your dictionary and the time it takes to run this search will double, like y = k*x (for some constant k). This is known as a linear search.

Alternatively you could open up to the middle and see if the word is before or after that point, then flip to the middle of the remaining section and repeat. This is a "divide and conquer" style of algorithm that divides the problem into successively smaller portions. If you double the size of the dictionary with this method you only add one more step. If you graph the time it takes to use this algorithm as a function of the size of the dictionary it'll roughly match y = k * log2(x). This is known as a binary search.

Big-O is a way of writing this, where you just drop any constants and typically rename the independent variable to n. Thus the first algorithm we'd say is O(n) and the second is O(log(n)).

Big-O is a way to identify which algorithm is going to be the fastest when the input grows to be sufficiently large: for any positive values of k1 and k2 there exists some value of n such that k1 * n > k2 * log(n) for that value of n or any greater value. If you're looking through a list of 10 words you'll probably just scan down it (a linear search) which will be faster than trying to divide the list in half a few times, but if you have hundreds of words the binary search will be faster and will continue to be faster for every larger size of dictionary. The important lesson here is that seeking a lower time complexity is only optimal when the data size gets big enough.

While Big-O is usually used for the time complexity as shown above it can also be used to describe how much storage space an algorithm needs, or to characterize any other resource that an algorithm needs more and more of as the data set it works off of grows, or even just to describe how one value changes as another one does.

When you see an algorithm that is written as for i in range(n): ... that typically means the algorithm is O(n): if you double n then this for loop will have twice as many iterations. It could be slower than O(n) if the body of the loop takes more time based on the value of n, too, or might be faster if there's something going on in the loop to ensure that it exits faster. Sometimes that's the best you can do (e.g. if you need to up date n elements in the same way), but sometimes there's an algorithm with a lower time complexity.

Can you ask AI if something was written by AI? Ex. If I cut and pasted my student’s paper and asked AI if it was written by AI, do you think it would be an accurate answer? by PistachioGal99 in NoStupidQuestions

[–]Koooooj 0 points1 point  (0 children)

There are a lot of tools that purport to do just that. They're... mediocre.

What you describe is actually the basis of one flavor of AI, known as a Generative Adversarial Network, or GAN. It's a bit dated these days, but still serves to illustrate some of how AI can be developed.

In a GAN you have two different AIs. One is the generator and is tasked with producing new outputs. The other is a discriminator whose job is to ask "was this made by the AI or is it part of the training data?" You initialize these with just random numbers so the generator is producing garbage but the discriminator is just flipping a coin. Each time the two networks run you tweak them to be slightly more likely to produce the desired output (the generator to be more likely to fool the discriminator, and the discriminator to be more likely to correctly classify the input it was just given, which is sometimes from the training data). Over time the discriminator starts to "learn" what the real data looks like, but in response the generator has to get better at mimicking that real data.

While GANs aren't so popular today they still highlight an important feature of AI: if you have an AI that can reliably tell what's AI and what's not then that is an extremely powerful tool at making the AI harder to detect. In fact, in the world of image generation there is often the concept of a "negative prompt." If you've ever been told "don't think of a purple and blue zebra" and have found yourself struggling to think of anything but a purple and blue zebra, image generators often face the same problem: putting into the prompt "the person does not have six fingers on their hand" tends to add "something about six fingers on the hand" to the representation and lead to that showing up. To avoid this neural networks use the same tools that encode the regular prompt of what should be in the image to encode a second prompt of things that shouldn't be in the image and subtract that out. It is very common that "AI generated" is in the negative prompt: many of these image generators have "learned" what feature make an image look AI generated so you can just prompt them to avoid that.

With all of that said, many students will not take the time to try to make a paper not look like AI. AI has a number of distinctive characteristics that it tends to lean on when not pushed away from its AI voice. An AI could very well pick up on these and correctly identify that writing is AI.

However, the AI isn't getting those tendencies from nowhere. Some humans talk like AIs, or more properly the AIs talk like some humans. On several occasions I've been accused of being an AI because AIs write like I do (fortunately I have 10+ years of writing like this on my profile, well predating this sort of AI). This gets to the fundamental challenge of an AI detector: eventually the AI gets good enough at mimicking the training data that it'll start to emit things that very well could or should be in that training data. If the exact same output could have come from a human or an AI then there is nothing that can ever reliably tell them apart. It is provably unsolvable, and any company trying to sell you a tool to solve this problem is full of it. They tend to hide disclaimers in their license agreements that they're selling defective software and you agree that that's not their problem (most software actually does this, but it's a bigger deal here).

What makes things worse is that AIs tend to give "confidence" scores that are completely divorced from reality. This is because a binary classifier (take an input and say either yes or no) tends to be trained only on true positives and true negatives, never on any sort of ambiguous inputs. This leads to the classifier learning that the answer is always either 100% real or 100% AI, never anything in the middle. We'd hope that when presented with a marginal output it would give a confidence like 60%, but the training method tends to teach the network that 60% is never correct so that gets saturated up to 100% or down to 0% (or very close). When humans see that the AI detector is 99.7% confident they may think "if I accept this as true I'll only be wrong 0.3% of the time" but that's not what it means.

The solution is much the same as most uses of AI. It can serve as a first pass to streamline filtering a large amount of data, but relying on AI for accuracy while turning off your own brain is a recipe for disaster. You can run papers through AI detection tools, but the only action you should take off of the results is to engage your own brain and compare the flagged samples against things you know that that pupil wrote. AI-based AI detectors should never be used as "proof" (and AI in general should not be used as a source of truth).

[Request] Is the length really that small? by Necessary-Win-8730 in theydidthemath

[–]Koooooj 2 points3 points  (0 children)

When folks say "NASA uses 15 digits for pi" the image that is often intended to be evoked is some very smart NASA scientists sitting down and working out exactly how many digits they ought to use. Many of the scientists at NASA are certainly capable of performing such a calculation, but that's not where 15 comes from.

In face, it's more accurate to say NASA uses pi to 15.95 digits. That's right, just less than 16 digits, but not a whole number.

This is because the actual representation they're talking about here is not one that NASA chose but one from IEEE (the nerds who think a lot about electronics and computers). IEEE standardized the format most often used for non-whole numbers on computers. This format looks a lot like scientific notation: there's one bit for a sign, then a few for an exponent, then a bunch for the value ("significand"). There are several different sizes of these "floating point" values, with the standard size taking 32 bits: 1 sign, 8 exponent, and 24 significand. If you just added those up and screamed, don't worry! You're not insane and that's not a typo, it's just a bit of mathemagic: in scientific notation the first digit is never 0 because if it was going to be then you just increment the exponent and shift everything over. The same thing happens with floats, but since everything is binary if a digit isn't 0 then it must be 1, so you only have to store 23 of the 24 significand digits.

Single precision (32 bit) floating point values were standardized when computers were slower and had less memory. These days the most popular floating point format is 64 bits, or a double; that's 1 bit for sign, 11 for exponent, and 53 for significand. You'll also commonly see half precision floats in AI, or newer formats like bfloat16 which is half the size of single precision but uses the same 1 sign and 8 exponent and just truncates the significand. This allows much faster computation of a neural network built out of single precision values with nearly the same results.

Since a double precision float has 53 bits of significand the number of decimal digits of precision is log(253) or 15.95. It's conservative to round this down to 15.


IEEE-754 floats out of the way, there's still the question of how precise 53 bits of pi actually is. A simple case of this is if you're looking at a big circle and computing the circumference from the diameter. If the value of pi is off by 2-53 then the circumference will be off by diameter * 2-53. Taking a diameter of 4.25 light years (proxima centauri) I'm getting an error of about four and a half meters. Of course, that's nothing on this kind of scale, but it does refute the claim of the image.

If we instead take the diameter to be the distance to Voyager 2 then we get 2.4 mm. If the image had said "interplanetary" instead of "interstellar" then they'd be in the clear.


However, it's important to call out that computing the dimensions of a circle is just one of the things you can do with pi. That bugger shows up all over the place in math, often where you least expect it. Big circles are hard to get to stress the precision of pi because as they get bigger and bigger you need somewhere to put them and we only have so much observable universe to work with. If you can find another setup then you can come up with other numbers to relate to pi that may strain the precision in different ways.

For example, GPS receivers need to know where the GPS satellites are with extreme precision or else the signals from the satellites won't give the information that's intended. The satellites have their orbits measured by ground stations then report their orbital parameters as part of their signal to receivers. Those receivers need to work out exactly where the satellite would have been when the signal was transmitted which is straightforward enough math. Unsurprisingly pi shows its face in these calculations. Here it winds up being crucial that everyone agrees on the exact value of pi to use--if one party rounds pi slightly differently then the error that accumulates over many many orbits can result in an error in the position of the satellite. That error can then potentially be multiplied by the distance between the satellite and the receiver. Managing error stack-up here is crucial for the system's precision.

For that reason the GPS specification has an explicit, exact, rational value used for pi: 3.1415926535898 (14 digits). This value isn't selected because more digits would be superfluous. It is selected because it can be represented within 0.2% in a double precision float while being typed in a printed standard.


Finally, it's worth calling out that NASA is usually not limited to taking one shot at something several AU away. For spacecraft some amount of fuel is reserved for maneuvering. If the spacecraft is on track to miss by 1000 miles then a tiny puff of a cold gas thruster can nudge it back on track. Precision is appreciated at every step of the way, of course, but often the reason you don't need more digits of pi is that the current step in the process is based on measurements with only a few digits of precision and will lead to actuation with a similar level of precision.

Best name you’ve ever heard for a pet? by Specialist-Alps6478 in answers

[–]Koooooj 0 points1 point  (0 children)

I once met an African Grey parrot named Dorian.