Help!! cant get this program to run

this are the errors that i get:
1>c:\users\ismael\desktop\hw8\hw8\hw8.cpp(9) : error C2365: 'y1' : redefinition; previous definition was 'function'
1> c:\program files (x86)\microsoft visual studio 8\vc\include\math.h(460) : see declaration of 'y1'
1>c:\users\ismael\desktop\hw8\hw8\hw8.cpp(27) : error C2065: 't' : undeclared identifier
1>c:\users\ismael\desktop\hw8\hw8\hw8.cpp(28) : error C2659: '=' : function as left operand
1>c:\users\ismael\desktop\hw8\hw8\hw8.cpp(39) : error C2659: '=' : function as left operand
1>c:\users\ismael\desktop\hw8\hw8\hw8.cpp(48) : error C2659: '=' : function as left operand
1>c:\users\ismael\desktop\hw8\hw8\hw8.cpp(57) : error C2659: '=' : function as left operand
*********************************************************
#include <stdlib.h>
#include <stdio.h>
#include <math.h>


//globals
double y1,y2,y3,dt,k1,k2,k3,k4,L1,L2,L3,L4,m1,m2,m3,m4,y1old,y2old,y3old,told,y1new,y2new,y3new,tnew,ans1,ans2,ans3;
int i;
//FPS
double eqn1(double y2, double t);
double eqn2 ( double y3);
double eqn3 ( double y1, double y2, double t );

void main ()
{
//input by replacement
told=1.0;
y1old=0.0;
y2old=1.0;
y3old=2.0;
dt=0.1;
//LOOP
for (i=0;i<=9;i=i+1)
{
//update 1
t = told;
y1 = y1old;
y2 = y2old;
y3 = y3old;
//get K1,L1,m1

k1 = eqn1 (y2,t)*dt;
L1 = eqn2 (y3)*dt;
m1 = eqn3 (y1,y2,t)*dt;

//update #2
t = told + dt/2.0;
y1 = (y1old + k1/2.0);
y2 = (y2old + L1/2.0);
y3 = (y3old + m1/2.0);
// get k2,L2,m2
k2 = eqn1 (y2,t) *dt;
L2 = eqn2 (y3) *dt;
m2 = eqn3 (y1,y2,t)*dt;
//update #3
t= told +dt/2.0;
y1=y1old + k2/2.0;
y2= y2old + L2/2.0;
y3= y3old + m2/2.0;
// get k3,L3,m3
k3= eqn1 (y2,t)*dt;
L3= eqn2(y3)*dt;
m3= eqn3(y1,y2,t)*dt;
//update#4
t= told+ dt;
y1= y1old+ k3;
y2= y2old + L3;
y3= y3old +m3;
// get k4,L4,m4
k4= eqn1(y2,t)*dt;
L4= eqn2 ( y3)*dt;
m4= eqn3(y1,y2,t)*dt;

y1new= y1old + (1.0/6.0)*(k1+ 2.0*k2 + 2.0*k3 + k4);
y2new= y2old + (1.0/6.0)*(L1+ 2.0*L2 + 2.0*L3 + L4);
y3new= y3old + (1.0/6.0)*(m1+ 2.0*m2 + 2.0*m3 + m4);
tnew= told + dt;
y1old= y1new;
y2old= y2new;
y3old= y3new;
told= tnew;
//close loop

}
// end main
return;
}

// These subs go after closing main


double eqn1( double y2, double t)
{
ans1 = y2-t;
return(ans1);
}

double eqn2 (double y3)
{
ans2=y3;
return(ans2);
}
double eqn3 ( double y1, double y2, double t)
{
ans3=6.0* y2-12.0*y1*t*t;
return(ans3);
}
y1(x) is a math function in math.h already which may you don't realize that. Change your global "y1" to any other name.

"y1(x) Bessel function of x of the second kind of order 1" in math.h

By the way, please use "code" past function to copy your code into the forum.
Last edited on
Topic archived. No new replies allowed.