# How do I solve and plot the equations for an RC circuit?

Posted 9 years ago
7583 Views
|
8 Replies
|
5 Total Likes
|
 I am trying to solve the and plot the equations for an RC circuit. What I have so far is v'[t] == (1/c)*(i[t] - v[t]/r) Any help would be appreciated.Thanks
8 Replies
Sort By:
Posted 9 years ago
 Thank you David.
Posted 9 years ago
 Hi Jake,I was mistaken when I said your equation was incorrect. That's the equation I gave for a parallel RC circuit. The only difference being you are taking i[t] as a given and you are solving for v[t]. I didn't notice that they were the same equations in different form. I think your notebook looks great.Kind regards,David
Posted 9 years ago
 Here is my program, and it matches my neuroscience book. I was missing the first line of code. Attachments:
Posted 9 years ago
 Hi Jake, I think your equation is incorrect. For parallel (trivial) and series RC circuits driven by an arbitrary v[t] I get the solutions below. (Sorry about Out[4] -- this new code system seems awkward at best.) In[1]:= parallelEq = i[t] == c v'[t] + v[t]/r Out[1]= i[t] == v[t]/r + c Derivative[1][v][t] In[2]:= (* trivial *) DSolve[parallelEq, i[t], t] Out[2]= {{i[t] -> (v[t] + c r Derivative[1][v][t])/r}} In[3]:= seriesEq = v'[t] == r i'[t] + i[t]/c Out[3]= Derivative[1][v][t] == i[t]/c + r Derivative[1][i][t] In[4]:= DSolve[seriesEq, i[t], t] Out[4]= {{i[t] -> E^(-(t/(c r))) C[1] + E^(-(t/(c r))) \!$$\*SubsuperscriptBox[\(\[Integral]$$, $$1$$, $$t$$]$$\* FractionBox[ RowBox[{ SuperscriptBox["E", FractionBox[ RowBox[{"K", "[", "1", "]"}], RowBox[{"c", " ", "r"}]]], " ", RowBox[{ SuperscriptBox["v", "\[Prime]", MultilineFunction->None], "[", RowBox[{"K", "[", "1", "]"}], "]"}]}], "r"] \[DifferentialD]K[1]$$\)}}
Posted 9 years ago
 Hi again -- I attach the notebook. It assumes we will know v[t] and want i[t] for each. Note that in the parallel case we don't need to solve a diffeq to get that. In the series case we do, and Mathematica supplies integration constants which can be used to accommodate initial conditions. Attachments:
Posted 9 years ago
 I am guessing from your wording that something didn't work, but I can't guess what.Can you be much much more specific about what you want, what you did and what went wrong?Or, if you start Mathematica fresh, type in the simplest example of exactly what you are trying to do, don't edit or replace or try again and again, just type (or paste, but even that can be more problematic) your problem, evaluate the whole notebook once, immediately save the notebook and attach that notebook to a post along with a clear simple verbal description of exactly what you were trying to accomplish and why it doesn't seem to be the result you were looking for then I'll give another try at what I hope will help you get where you want to go.
Posted 9 years ago
 Bill, this gave me more problems than I had!
Posted 9 years ago
 See if you can modify this In[1]:= i[t] = 4; r = 2; c = 3; sol = v[t] /. DSolve[{v'[t] == (1/c)*(i[t] - v[t]/r), v[0] == 0}, v[t], t] Out[2]= {8 E^(-t/6) (-1 + E^(t/6))} In[3]:= Plot[sol[[1]], {t, 0, 20}] Out[3]= ...PlotSnipped...