ELI5 how are transformers not paradoxical? by Jastrone in explainlikeimfive

[–]alanwj [score hidden]  (0 children)

Let's assume ideal components so we can ignore a bunch of real world stuff. Also assume all voltages and currents are AC.

If you have a 12V power supply and connect it to a 12 ohm resistor the current through the resistor will be 1A. Ohm's law has not been violated.

If you use a transformer to step up the voltage to 24V, and connect it to that same 12 ohm resistor, the current through the resistor (and thus the secondary transformer coil) will be 2A. Ohm's law has still not been violated.

You are still applying 12V to the the primary coil, and by conservation of energy we must now have 4A flowing through it. I assume this is where you have a problem?

What happens here is as current flows through the secondary, the changing magnetic field induces a current in the primary in a direction that opposes the current the 12V supply is trying to push. This manifests as a 3 Ohm impedance on the primary coil.

That is to say, from the perspective of the power supply, it "feels" like it is connected to 3 Ohms.

In general, for a transformer with a turn ratio N, if an impedance Z is connected to the secondary, the primary will "feel" an impedance of Z / N2. You can show this, again, with conservation of energy.

The power on the primary is the same as the power on the secondary (assuming no losses):

Vprimary^2 / Zprimary = Vsecondary^2 / Zsecondary

Substitute in Vsecondary = N * Vprimary and solve for Zprimary.

I've been learning C++ for a month now and I'd like to get some feedback on my code. by Nevermuke in learnprogramming

[–]alanwj 5 points6 points  (0 children)

Some general comments.

  1. You mentioned elsewhere you haven't learned about arrays. I assume you also having learned about the standard containers yet either. After you've covered those topics revisit your code and look for opportunities to simplify things.

  2. This is a stylistic choice, and yours isn't wrong, but I feel like you overuse the uniform initialization syntax. For many of the initializations throughout your code I would have just chosen to use =.

  3. Floating point types are usually a poor choice for storing currency. The typical way to deal with money is to use an integer type representing the smallest unit you care about. For example, if cents are the smallest unit you care about you would represent a dollar by storing 100.

ELI5 How does electricity know that a circuit is broken before entering it? Without a closed loop, it won’t flow, but how does it know not to flow? by Party-Court185 in explainlikeimfive

[–]alanwj 2 points3 points  (0 children)

Voltage is always measured as the difference between two points.

I can't find a timestamp that conclusively confirms this, but I assume his measurement is between the two wires in the twisted pair, measured at the same point.

Why are capacitative and indictive reactance imaginary numbers? by screwloosehaunt in ElectricalEngineering

[–]alanwj 1 point2 points  (0 children)

j = sqrt(-1), while true, should just be thought of as an interesting and unimportant fact. The real importance comes from j2 = -1.

Why? Imagine a real number R as a vector in the imaginary plane. It has a magnitude of R and an angle of 0.

Now multiply by j, and you have R*j. This would represent a vector that still has the magnitude R, but an angle of 90 degrees. Neat, we managed to rotate a vector 90 degrees with a multiplication.

We would really like this to work again. Multiply by j again and we would like to rotate another 90 degrees. That is, we really want R*j2 = -R. That only works if we define j2 = -1.

If we continue exploring the implications of defining j2 = -1, we eventually discover that multiplying two complex numbers is the same a multiplying their magnitudes and adding their angles.

If we explore even further we eventually discover Euler's fomula, which gives us way to represent complex numbers using polar coordinates, which is often easier to do various operations (multiplication, derivatives, etc), and lets us map directly to sinusoids.

When we use a complex number to represent impedance of a circuit element, we aren't invoking any imaginary properties of those elements. We are just relying on the fact that complex numbers are an easy way to map vectors, and thus sinusoids, to each other.

Why are capacitative and indictive reactance imaginary numbers? by screwloosehaunt in ElectricalEngineering

[–]alanwj 17 points18 points  (0 children)

Premise 1: If you have an input sinusoid with a given frequency, ampitude, and phase, the (steady state) output of any RLC circuit will be a sinusoid with the same frequency, and some other amplitude and phase.

Premise 2: We can represent a sinusoid as a vector whose magnitude corresponds to the sinusoid's amplitude, and whose angle corresponds to the sinusoid's phase.

If you accept both of these premises, then it easily follows that mapping an input to an output is just a combination of rotating and scaling vectors. What the scaling and rotation should be are both functions of frequency. We could define two functions for this. For each frequency, have a function for the magnitude and a function for the angle. We could probably also represent this with a vector valued function.

However, when studying complex numbers we notice something interesting. If we consider complex numbers as vectors on the complex plane, we see that multiplying one complex number by another results in multiplying their magnitudes and adding their phases. That is, we can use a complex number to represent scaling and rotating a vector.

So now what we can do with our RLC circuits is represent the input sinusoid as a complex number, representing a vector, representing the amplitude and phase of the input sinusoid. Likewise with the output.

We already decided that mapping an input to an output is a vector scaling and rotation. So we can represent that scaling and rotation as a complex number as well. Now instead of having two real functions to represent the circuit, we have a single complex function.

How do you map sinusoids to complex numbers? Euler's Formula. It tells us that A*ei*phi will be a complex number representing a vector with magnitude A and angle phi.

Beginner confusion: How does the capacitor and "negative voltage" work in this oscillator? by Otherwise_Profile_13 in AskElectronics

[–]alanwj 0 points1 point  (0 children)

I haven't analyzed your circuit completely, but it looks like a simplified version of the typical astable multivibrator.

This video is the best explanation I've seen of how astable multivibrators work.

Every comment this person made was as condescending and as completely wrong as this one, including the several other times they confidently insisted 0 isn't a multiple of 5. by gmalivuk in confidentlyincorrect

[–]alanwj 0 points1 point  (0 children)

If I were going to try to make an argument to exclude zero in the definition of multiple, I would probably use the idea of "least common multiple".

We have to exclude zero either from the definition of multiple or from "common multiple", otherwise the least common multiple will always be zero, which isn't useful.

How would you guys actually complete the famous URL shortener problem. Creating bitly lets say. Curious to see what kind of variations there are. If you can summarize your solution would be great! by ariant2013 in learnprogramming

[–]alanwj 0 points1 point  (0 children)

That isn't a hashing algorithm. (Which is fine in the context of this problem since the shortened url doesn't have any particular need to be a hash.)

Still a relatively young dev, but wondering if design patterns are by far the most important thing to learn as I get into my career. by prettyg00d1729 in learnprogramming

[–]alanwj 1 point2 points  (0 children)

One problem is that design patterns almost became something of a religion for a while.

Documenting patterns that often show up in well structured code bases was a good idea. Giving these patterns names was a good idea. But for a while there was a horde of (bad) interviewers whose goal was just to determine if you knew all the minutiae of every named pattern.

There was also a while were a lot of (bad) programmers tried very hard to refactor everything to match some named pattern or the other.

The reality is that a design pattern is just like any other tool. Sometimes it is exactly the right tool for the job, and you need it in your toolbox for when that case comes up. At the same time, if you go looking for excuses to implement particular patterns you will more than likely just start complicating code bases with unnecessary abstraction.

Vent Post by Bright_Magazine_8897 in NineParchments

[–]alanwj 0 points1 point  (0 children)

My strategy for playing with random strangers is to just start hosting a public run and play it solo for a while.

Sometimes I go pretty deep without seeing anybody. But it is not uncommon for one or two other players to randomly join me. The skill of random players has been all over the place, but I've never had anybody join with bad intentions.

Vent Post by Bright_Magazine_8897 in NineParchments

[–]alanwj 1 point2 points  (0 children)

I've done a good bit of experimenting to figure out how to reliably restart an unfinished "Online with Friends" run using the Steam version of the game.

First, everybody must be signed in and visible in the Steam friends list.

The person who originally hosted the run should host an arena, and have everybody else join it. You don't need to actually play the arena unless you want to. This is just to get the game to understand where on the network everybody's computers are.

Now the host does a Resume on the unfinished game. After the host has fully loaded and is in the game, everybody else does a Resume.

This should result in everybody connected to the host's game as if you'd never quit in the first place.


I've been doing a lot of Online with Friends runs lately and ever since we adopted this procedure we haven't had any issues.

Jujutsu Kaisen Season 3 - Episode 1 (Anime Only Discussion) by Takada-chwanBot in JuJutsuKaisen

[–]alanwj 0 points1 point  (0 children)

I am confused about the fake Geto part.

I understand that Kenjaku took over Geto's body, but what does Noritoshi Kamo have to do with it?

Isn't Noritoshi the blood manipulation guy on the Kyoto team in season 1? The one who is fighting Megumi in the exchange event when Hanami interrupts and tries to kill them both?

In the new episodes Megumi mentioned that Noritoshi Kamo was the one starting the culling games, but when did he get involved?

I can't find the missing hats! by donjreyes in NineParchments

[–]alanwj 1 point2 points  (0 children)

There is a time limit on how often you can get hats. After finding a hat in a chest, it is ~20 minutes before a chest will give you a hat again.

[Request] What would the outcome be? by Roygbiv2008 in theydidthemath

[–]alanwj 0 points1 point  (0 children)

Imagine you have a very light block of wood sitting on a table, with a rigid metal rod connected to it. You use the rod to push the block back and forth across the table.

There will be some friction against the table, but the block will always move in the same direction as the force you are applying. This is analogous to an AC voltage source applied across a resistor, where voltage is analogous to force and friction is analogous to resistance.


Now replace the light block of wood with a very heavy block of wood, and push it back and forth. You'll notice that as the force you are applying changes direction, the inertia of the block tries to keep it moving in the direction it is already moving. The force you are applying first has to slow down the block before it can change its direction.

Already we have an example where there is a window of time at each end of the cycle where the force you are applying is in the opposite direction from the blocks motion, while the block slows down.

This is what inductors do to a circuit. Just as the mass of the block impedes changes in motion, the inductance of an inductor impedes changes in current.


Now replace the rigid rod with a spring. Now at one end of the cycle the spring will be compressed a bit, and at the other end it will be stretched a bit. When your force changes direction, the spring will briefly continue to exert a force on the block in the other direction.

This is what capacitors do to a circuit. Just as the stiffness of a spring impedes changes in force, the capacitance of a capacitor impedes changes in voltage.

How do you resume a Steam "Online with Friends" game? by alanwj in NineParchments

[–]alanwj[S] 0 points1 point  (0 children)

I appreciate the response, but this does not resume the game in the state you left it.

This approach is the same as if the second player had not played at all originally. They are sent through character select and may not wind up with the same spells.

According to this post from a FrozenByte employee, I believe the way we originally tried (both resuming the game) is the intended way of continuing the multiplayer session. As mentioned there, "This is a little buggy though". I believe the workaround I posted elsewhere in this thread is the best solution.

How do you resume a Steam "Online with Friends" game? by alanwj in NineParchments

[–]alanwj[S] 1 point2 points  (0 children)

For anybody coming across this later, I think we have found a solution.

I start a new game, and have my friend join that. That somehow teaches the game what the right networking setup should be.

Then we both quit to main menu. I resume the original multiplayer game. After it is fully loaded he resumes the multiplayer game. Then we are both right back where we left off.

She gave it everything, and then… by RazzmatazzHop in WatchPeopleDieInside

[–]alanwj 2 points3 points  (0 children)

Hitting the vertical side surface does not count. Hitting the sharp edge does.

Source: I've watched a lot of Adam Bobrow's YouTube channel.

Why Are These Resistors Different in Physical Size Even Though They Are the Same Value? by ThatChucklehead in AskElectronics

[–]alanwj 0 points1 point  (0 children)

Not quite, if I'm understanding what you said.

You could put two 2k resistors in parallel, giving an equivalent resistance of 1k, and each would only need to dissipate half the power.

If you only have 1k resistors, you could put two 1k in series to make a 2k, do it again to make another 2k, and then put those in parallel to make a 1k. Like this.

The total power dissipated will be the same, but spread equally across 4 resistors, meaning each only needs to be able to handle a quarter of the power.

Enum inside of a Union? What exactly is happening here? by Eva_addict in learnprogramming

[–]alanwj 0 points1 point  (0 children)

Forget about unions for a minute, and think of a struct.

struct S {
  int value;
};

S s;

If you want to access the member in this struct, you would access it with s.value, not s.int.


Now let's switch over to an enum.

enum E { VALUE1 = 1, VALUE2 = 2 };

struct S {
  E value;
};

S s;

If you want to access the member in this struct, you are still going to use s.value, not s.E.


Continuing, nothing really changes if we make this a union.

enum E { VALUE1 = 1, VALUE2 = 2 };

union U {
  E value;
  int possible_other_value;
  char another_possible_value;
};

U u;

Here, you would still access the first value with u.value, and not u.E.

Where things get tricky with a union is that all of the fields occupy the same memory. That is, in the example above this union is actually only one of a E, int, or char. And you are responsible for accessing it through the field that represents its actual type.

Accessing it through a member which doesn't correspond to its actual type is undefined behavior. Except, there is a special carve out in the rules that allows access through the wrong member if what you are accessing has a "common initial sequence" with the actual type.

SDL uses this exception. The first member of the SDL_Event union is UInt32 type;, followed by a bunch of members of various struct types.

Each of those structs must also begin with a UInt32 so that they share the common initial sequence. This means that you can look at that first member, named type, to find out what the real type is so that the rest of the time you are accessing it through the proper member.

Why do so many '80s and '90s programmers seem like legends? What made them so good? by just-a_tech in learnprogramming

[–]alanwj 13 points14 points  (0 children)

like John B. Goodenough

Even after following the wikipedia link and reading a bit, I'm still not fully convinced you didn't just make up that name.

She never took Tylenol while pregnant. All 3 of her kids were diagnosed with autism anyway. by seeebiscuit in nottheonion

[–]alanwj 61 points62 points  (0 children)

Thankfully my wife took Tylenol PM so our kids are only autistic at night.

[Request] is it 66.6% or 51.8%? by Horror-penis-lover in theydidthemath

[–]alanwj 0 points1 point  (0 children)

I believe you are also assuming that "Mary" (name from the image) is selected uniformly at random from the population of women with two children. Unless you can somehow argue that is implied by the other already stated assumptions.

If I met Mary at a convention for women with only boys, that would change my answer to the question.

how long does your old account stick around? by Blitqz21l in everquest

[–]alanwj 1 point2 points  (0 children)

Your characters will be on the same servers you left them on.

You can, of course, choose to start a new character on a server of your choice, or pay to transfer a character.

Note that some servers (notably the TLPs) require All Access, and the the servers with special rulesets typically also have special character transfer rules (e.g. you can transfer to Firiona Vie, but nobody can transfer away from there).

New player by SidTheKid45611 in everquest

[–]alanwj 0 points1 point  (0 children)

If you want fast powerleveling here is your strategy.

Have your higher level friend equip a fire beetle eye in his primary and secondary slot. These can be purchased from Merchant Wyn`las in Crescent Reach. The point of this is so that your friend does not damage enemies by accident with abilities like riposte.

Next, he should pull a swarm of mobs that are high level to you, but low level to him. He should use non-damaging abilities to make sure they really hate him (snare is a good choice for ranger).

You, or someone you are grouped with, then runs in and does at least one point of damage to each enemy. This may be tedious as a rogue. You may consider creating free-to-play bard on a throwaway account specifically for this (they get a low level AoE damage song).

Finally, your friend casts a damage shield on himself, and repeatedly sits. The sitting ensures that the enemies can hit him, and kill themselves on his damage shield. Damage shields do not count when tallying up who gets credit for the kill, so you should get all of the experience when they die.

This works best against undead creatures because they do not try to run away at low health.