Reply
Old 12-08-2011, 07:38 AM   #1 (permalink)
 
Status: Junior Member
Posts: 7



Default whats wrong with this program, please help?

Problem: Numerically solve the following differential equations using the Euler method
du/dt = v
dv/dt = -kv - u³ + B cos(t)
with k=0.1, B = 11.0,
and plot the result using gnuplot. Change the parameters to k=0.4, B =20.0 and show the graph as well. You can use the initial condition as u(0)=1, v(0)=1. Also use h=0.01, i=10000.



Program:
#include <stdio.h>
#include <math.h>

double f(double t, double y)
{
return y;
}
int main()
{
double h=0.1, y, t, B, k, x;
int i;
t=0.0; y=1.0; k=0.1; B=11.0;
for (i=0; i<=10000; i++)
}
printf("t=%lf %lf %lf\n", t, y, -k*y - x*x*x + B*cos(t)); y=y+h*f(t,y); t=t+h;
}
return 0;
}

please help I have to plot and everytime I try an error occurs so I'm pretty sure there is an error in the program. I'm a beginner at programming and I'm also not too familiar with Euler's Method...any help is appreciated thanks.
IHave is offline   Reply With Quote
Old 12-08-2011, 07:38 AM   #2 (permalink)
 
Status: Junior Member
Posts: 1



Default whats wrong with this program, please help?

I just had a quick look,for every open bracket there should be a corresponding closed bracket (please check this)
Also where should the main() occur,is it occuring at wrong place?.Also check for other syntax like ;after B=11.0 etc is it correct ?
I need more time to study this to find out other errors.
Maestro1 is offline   Reply With Quote
more..

Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
whats wrong in this program ? map06 Programming 2 01-21-2014 03:06 AM
whats wrong in my program... plz help? ANGELGAL Programming 1 02-20-2013 08:04 AM
Whats Wrong with my HTML Image Map??? Should be working...whats wrong.? Kanada Html Code/ Html Codes 1 02-13-2012 07:08 AM
whats wrong with this program? Unknown_User Programming 1 01-17-2012 05:36 AM
Whats that program called(that tell you whats wrong with you) clara21 Computer Programming 2 07-08-2011 08:10 PM