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- differential equation

Status
Not open for further replies.

CJDeeds

Technical User
May 11, 2013
3
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?
 
Guidance? That's a very general request. Can you narrow it down? Even better, can you make it a fortran question?

Have you tried to solve this?, how? where exactly are you stuck?

Say, y[sub]n+1[/sub] shows up on both sides of the equation, what's up with that?

Forgive my ignorance on solving differential equations [dazed]

A quick google search yielded a few things like

Explicit Euler Method, where you approximate your y' by
(y[sub]n+1[/sub] - y[sub]n[/sub]) / h
and so
y[sub]n+1[/sub] = y[sub]n[/sub] + h x f(t[sub]n[/sub],y[sub]n[/sub])


 
WSUPhys has asked the same question on the C++ Unix forum. Assuming you are both the same person, do you need guidance on the math or the programming?
 
It is more the programming, I had originally posted in here but realized after looking at the original request that it is supposed to be coded in C++, thank you though.
 
CJDeeds said:
I know that in order to solve this I need to use the trapezoidal method to solve a differential equation
How do you know this? Have you tried it to solve by other method before?
To be clear: the method you want to use is implicit method. It's not so simple to program like explicit method -e.g. suggested by salgerman.
If you want to use implicit method then in every step you will have to find y[sub]n+1[/sub] by solving nonlinear equation Phi(y[sub]n+1[/sub]) = 0.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top