# Use Mathematica and Kirchhoff's rules to find V out.

1. Jul 1, 2013

### stripes

1. The problem statement, all variables and given/known data

Find V out by determining three equations with three unknowns. Use Mathematica to solve the system to find V out. See image for details

2. Relevant equations

--

3. The attempt at a solution

Here is my code:

$\text{eq1}=v-i_3*(2r)-i_3*r-i_3*(2r)$
$\text{eq2}=-v+\left(i_2-i_3\right)*(2r)+i_2*r+\left(i_2-i_1\right)*(2r)$
$\text{eq3}=v-\left(i_2-i_1\right)*(2r)-i_1*(2r)$

Then I just solve the system in Mathematica by:

Code (Text):
sol=Solve[{eq1==0,eq2==0,eq3==0},{i[SUB]1[/SUB],i[SUB]2[/SUB],i[SUB]3[/SUB]}]

So my first question is, did I get the system right? This is actually a third year course where we're programming some stuff from lower-level courses...and I haven't used Kirchhoff's rules in many years. So I have forgotten it.

After this I'm not sure how to find V out. In mathematica, I figured it would be:

Code (Text):
vout = v - i[SUB]3[/SUB]*(2 r) /. sol
But the answer is not correct. We should end up with V out = (5/8)*v, but when calculate it with the above equations/code, I get v out = (3/5)v.

If someone could help I would appreciate it.

#### Attached Files:

• ###### Capture.JPG
File size:
21.4 KB
Views:
111
Last edited: Jul 1, 2013
2. Jul 1, 2013

### Staff: Mentor

Assuming that you are writing mesh equations for the loops, shouldn't there be an i2 term in eq1?

3. Jul 1, 2013

### stripes

yes, eq1 should be

$\text{eq1}=v-i_3*(2r)-i_3*r+\left(i_2-i_3\right)*(2r))$

but i still cannot get the right answer of 5/8 v

4. Jul 1, 2013

### Staff: Mentor

Check to make sure that the signs of all terms are correct in eq3. Do they agree with your chosen mesh current directions?

5. Jul 2, 2013

### stripes

Thanks gneill. For eq 3 I now have:

$\text{eq3}=v+\left(i_2-i_1\right)*(2r)-i_1*(2r)$

Now how do I go about finding V out. Like I said my knowledge of circuits is very limited as I don't even remember learning this stuff. If I did it would have been many years ago. I've had to learn it as I go, though it isn't very difficult. I just don't actually know how to find V out. Thanks again.

6. Jul 2, 2013

### Staff: Mentor

The tricky part about writing mesh equations lies in keeping the current directions consistent and remembering whether, when you're going around a loop, you're summing potential rises or potential drops. Once you've made those choices you've got to stick to them for every loop, otherwise sign errors will creep in for various terms.

Your equations seem to be exhibiting some effects of the above and I'm not sure that your 'corrections' have been much better, possibly due to lingering inconsistencies with current direction choices in in the remaining equations. So let's redo the equations starting with a firm statement of the conditions. The default choice for loop current direction is clockwise. So here's your circuit with loop currents identified and the resulting potential changes penciled-in for each current.

If the choice is to sum potential drops (so potential drops are treated as positive values when writing the equations), can you write the equation for the first loop (associated with current i1)?

File size:
6.1 KB
Views:
300
7. Jul 2, 2013

### Bill Simpson

Hint: What is i3*2R and why should that be interesting for you?

If you actually did REALLY learn this stuff once then I urge you to track down the particular textbook you learned this stuff from, maybe on Amazon or Abebooks or any of the other used book warehouses, and buy a copy of that specific book. Often used books of that age can be had for a dollar plus three for shipping.

Why that particular textbook? Because, despite I cringe when saying this, the font... and the examples and the feel of the pages and even the smell of the pages will help too and probably bring back brain cells that you would think were long since dead.

I still have my original calculus text on the shelf. When I just cannot see why I am making some stupid mistake I flop that open and page back and forth, wonder how in the world I thought all of this was so hard the first time through it, and the memories start coming back.

I urge you to not substitute some other introductory DC circuits text, I don't think the effect will be nearly as strong if you do, but it would be better than nothing.

And learning something all over again the fourth time is the way you really learn it anyway.

8. Jul 3, 2013

### stripes

I still think it's:
eq1 = -v + i1*2r + i1*2r -i2*2r

which is the same thing that i most recently posted (but the directions are just different). Using the same conventions, the other two equations would be:

eq2 = v -i2*2r + i1*2r -i2*r -i2*2r + i3*2r

eq3 = -v + i3*2r -i2*2r + i3*r + i3*2r

And Bill I'm not that old yet :) regarding your hint...that was in the example he gave us and I also thought about it a little but I have since forgotten why that specific equation is important to be honest.

9. Jul 3, 2013

### stripes

Interesting I just put those new equations into my Mathematica notebook and I got the answer 5/8 V. Before i get worked up thinking i've solved the problem...did I do this correctly? Perhaps two wrongs made a right here...and I don't want that...

10. Jul 3, 2013

### stripes

posting again...scratch that...i got 5/8 v but...my v out equation it hink was wrong, so i'm back at square one.

11. Jul 3, 2013

### Staff: Mentor

The voltage source represents a voltage DROP going in the direction of the loop current, so if you're summing voltage drops (as it would appear you are doing with the rest of the terms), v should be positive.
Despite what you claim, you seem to have changed conventions here, since you're now summing voltage rises rather than drops. But that's okay.
As in the first equation, you've got the sign of the voltage supply term reversed; the rest of the terms show that you're summing voltage drops, and the supply represents a drop in the direction of i3.

12. Jul 3, 2013

### stripes

So they've all got to be positive? I just always figured that for the middle loop, the voltage term would be of a different sign since the battery is placed differently.

13. Jul 3, 2013

### Staff: Mentor

It would have been of a different sign had you not switched from adding drops to adding rises in that loop. All the other terms would change sign, too.

14. Jul 3, 2013

### stripes

Then to find Vout, we use

Code (Text):
vout = v + (Subscript[i, 3])*(2 r) /. sol;
or
Code (Text):
vout = v - (Subscript[i, 3])*(2 r) /. sol;
depending on the conventions in the first three equations?

15. Jul 3, 2013

### Staff: Mentor

I suppose so. I'm not a frequent user of Mathematica; I make more use of MathCad and tend to use a matrix approach for simultaneous equations. The matrix approach is particularly handy for mesh equations since the matrix can be written by inspection without working up the loop equations individually.

16. Jul 4, 2013

### stripes

In the assignment we learned the matrix way of doing things as well. I just chose not to use that method because the code isn't as neat. But thanks again for all of your help everyone.

17. Jul 4, 2013

### Bill Simpson

I understand that Windows and desktop publishing have made many people think they just have to use subscripts in Mathematica.

Subscripted variables are not first class citizen "real variables" in Mathematica and they can and will come back to bite you in ways you can't begin to imagine. Sometimes they will work for you. Many many times they will not. That was a design decision made in Mathematica many years ago and it cannot be changed now.

If you can give up everything you hold dear and just use i3 instead of Subscript[i,3] and even Bold[ReverseItalic[ OldeEnglishFont[BrightPink[ GentlyDancingBackAndForth[ SubscriptedButWithADifferentFontFor3[i,3]]]]]] you will more likely get the correct answer.