Hi, kleine off-topic frage: ich moechte numerisch folgendes integral mit Octave oder Scilab (beides ist Matlab recht aehnlich, das hab ich aber nicht) loesen: (TeX Math expression, gerendertes PNG ist attached) \begin{align} Q_x & = \int_0^x\left(\frac{U-\frac{Q_{x-dt}}{C}}{R}\right)dt \\ Q_0 & = 0 \\ \end{align} Das Problem ist, dass ich da in der funktion ueber die ich integriere das integral von 0 bis x-dt verwende. Ideas or hints anyone? yours, - clifford -- If Python is executable pseudocode, then perl is executable line noise.
On Dec 28, 2007, at 1:40 AM, Clifford Wolf wrote:
Das Problem ist, dass ich da in der funktion ueber die ich integriere das integral von 0 bis x-dt verwende. Ideas or hints anyone?
I guess you already know this, but in case you need some hints, this is the first thing which comes to mind (I've long forgotten the math behind this though): You're obviously trying to solve a RC circuit. Since the voltage in question is dependant on the current going through the circuit, which again is dependant on the derivate of the voltage, you get a differential equation. Exactly how such software packages solve differential equations numerically, I don't know, but I guess you might have to specify the equation on some standard form for differential equations, not in form of an integral using it's own partial result. Alternatively, if you google a bit, you'll probably find the resulting exponential function and can substitute that one instead, unless this is part of a larger, more complicated circuit, and unless you're solving it numerically for some other reason. ..or ask Isis how to solve such differential equations analytically ;) ~/= Marius -- We are Elektropeople for a better living.
Hi, Marius Kintel (kintel@sim.no) wrote on 2007-12-28:
Exactly how such software packages solve differential equations numerically, I don't know, but I guess you might have to specify the equation on some standard form for differential equations, not in form of an integral using it's own partial result.
To solve ordinary differential equations numerically, you usually have to get them to a form where the derivatives are explicitly computed from the "current" values. For your equation, that simply means differentiating with respect to time so that you have $\frac {dQ}{dt} = \left(\frac{U-\frac{Q}{C}}{R}\right)$ In octave, it looks like this (with a variable U, so that it's not entirely pointless to solve it numerically): function Qdot = f(Q,t) U = 1.0 + .2*sin(t); R = 2.0; C = 3.0; Qdot = 1/R * (U-Q/C); endfunction tMin=0 tMax=50 nSteps=200 Q0=0 tValues = linspace(tMin,tMax,nSteps); Qresult = lsode("f", Q0, tValues); plot(tValues,Qresult); ciao, -- [*Thomas Themel*] A friend of mine, when asked what he wanted from Santa [extended contact] for Christmas, replied, "A crater the size of DC." [info provided in] [*message header*] - Eric Cordian on cypherpunks
Hi again, thanks Marius and Thomas, after getting some sleep its also not that confusing anymore.. ;-) On Fri, Dec 28, 2007 at 06:38:41AM +0100, Thomas Themel wrote:
Hi, Marius Kintel (kintel@sim.no) wrote on 2007-12-28:
Exactly how such software packages solve differential equations numerically, I don't know, but I guess you might have to specify the equation on some standard form for differential equations, not in form of an integral using it's own partial result.
To solve ordinary differential equations numerically, you usually have to get them to a form where the derivatives are explicitly computed from the "current" values. For your equation, that simply means differentiating with respect to time so that you have
$\frac {dQ}{dt} = \left(\frac{U-\frac{Q}{C}}{R}\right)$ [..]
oh yes, thanks - it's also _much_ easier to read now.. ;-) yours, - clifford -- A: No. Q: Should I include quotations after my reply?
Teilnehmer (3)
-
Clifford Wolf -
Marius Kintel -
Thomas Themel