5 Replies - 477 Views - Last Post: 11 May 2013 - 07:48 PM Rate Topic: -----

#1 ShoxPhysics  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-May 13

Trapezoidal Method- differential equation

Posted 11 May 2013 - 04:37 PM

Hello,
I am working on a program to find the value of the current in a coil. This value satisfies the following equation:
y'=sin(2t)-[(ey-1)/(ey+1)]

which is of the form y'=f(t,y)

I know that in order to solve this I need to use the trapezoidal method to solve a differential equation, the formula is:
yn+1=yn+.5*h(f(tn,yn)+f(tn+1,yn+1) where h=tn+1-tn

I have found examples of the standard trapezoidal method but I do not think they will help because of the difference in the formulas. Can anybody give me some guidance here?

Is This A Good Question/Topic? 0
  • +

Replies To: Trapezoidal Method- differential equation

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10443
  • View blog
  • Posts: 38,678
  • Joined: 27-December 08

Re: Trapezoidal Method- differential equation

Posted 11 May 2013 - 05:26 PM

This is a numerical approximation technique. Basically, you start off with an initial y-value. So y(t) = y0. Then y1 = y0 + timeDifferential * average(y0, y1). So are you looking 0.10 time units out? 1 time unit out? Whatever your time interval is, plug that in for your timeDifferential variable.

If you are familiar with Euler's method, this is essentially that method.
Was This Post Helpful? 0
  • +
  • -

#3 ShoxPhysics  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-May 13

Re: Trapezoidal Method- differential equation

Posted 11 May 2013 - 06:42 PM

could you please explain some more?
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10443
  • View blog
  • Posts: 38,678
  • Joined: 27-December 08

Re: Trapezoidal Method- differential equation

Posted 11 May 2013 - 07:10 PM

What specific questions do you have?
Was This Post Helpful? 0
  • +
  • -

#5 ShoxPhysics  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-May 13

Re: Trapezoidal Method- differential equation

Posted 11 May 2013 - 07:33 PM

I am just having trouble understanding how to start coding the trapezoidal method for differential equations because the majority of the examples I have found utilize the simpler trapezoidal method for derivatives but not how to handle it for the differential equation y'=f(t,y). I am relatively new to coding in C++, the majority of my experience is in Fortran but the assignment requires that it be coded in C++.
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10443
  • View blog
  • Posts: 38,678
  • Joined: 27-December 08

Re: Trapezoidal Method- differential equation

Posted 11 May 2013 - 07:48 PM

You do understand that the trapezoidal method for a derivative means the solution for a differential equation, right? A differential equation is an equation with derivatives in it.

Essentially what you want to do is loop until you're happy with the value. It could be 10 iterations, 100 iterations, iterate until the difference in y(n) and y(n+1) is less than some epsilon value, etc. The formula is pretty cookbook in nature.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1