Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapezoidal method

Status
Not open for further replies.

WSUPhys

Technical User
Feb 6, 2013
20
US
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)-[(e[sup]y[/sup]-1)/(e[sup]y[/sup]+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:
y[sub]n+1[/sub]=y[sub]n[/sub]+.5*h(f(t[sub]n[/sub],y[sub]n[/sub])+f(t[sub]n+1[/sub],y[sub]n+1[/sub]) where h=t[sub]n+1[/sub]-t[sub]n[/sub]

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?
 
Do you need guidance in the math or the programming?
 
the programming, I know how the math behaves but I am unfamiliar as far as how to write this in C++ code.
 
I am totally ignorant as to what is required. Do you need a load of y values given a set of t values or the y and t value when they satisfy some condition like y' is zero. I also don't really know how you would solve something like

yn+1=yn+.5*h(f(tn,yn)+f(tn+1,yn+1)

because yn+1 appears on both sides. Assuming h is really small, why not use the Euler form of

y(n+1) = yn + h * f(tn, yn)

In that case, the same question arises: do you want all the values given a starting t0 and y0 up to a particular value of tn or do you just want it satisfying some criteria.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top