Hello, I'm still getting the hang of coding (just started a few weeks ago) so this may seem like a daft question. I keep on getting three errors when I run my code:
ode_functions.c
f:\ode_functions.c(41) : error C2296: '^' : illegal, left operand has type 'double'
f:\ode_functions.c(41) : error C2297: '^' : illegal, right operand has type 'double'
f:\ode_functions.c(41) : error C2198: 'sqrt' : too few arguments for call
Here's an overview, ode_functions.c is called on by ode_main.c. ode_main.c also calls on ode_functions.h. Not only this, but there are three more header files and one more source file, ode_methods.c which implements the Euler and Improved Euler methods.
I'll print out ode_functions.h and ode_functions.c. I'll also print out the relevant bits of ode_main.c.
ode_functions.c:
#include <assert.h>
#include "ode_functions.h"
#include <math.h>
double function3_derivative(double x, double y){
double H, V, vo;
double temp = (vo * sqrt((H - x)^2 + y^2) - V * y)/ V*(H - x);
return temp;
}
ode_functions.h:
#ifndef _ode_functions_h_
#define _ode_functions_h_
double function3_derivative(double x, double y);
#endif
ode_main.c:
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include "allocate.h"
#include "error.h"
#include "fileio.h"
#include "ode_methods.h"
#include "ode_functions.h"
int main(void)
{
code code code code
double H, V, vo;
printf("Enter the function number: ");
scanf("%d", &function_number);
switch (function_number) {
case 1:
dydx = function1_derivative;
break;
case 2:
dydx = function2_derivative;
break;
case 3:
dydx = function3_derivative;
break;
default:
ERROR("Unknown function number");
}
if (function_number = 3){
printf("Enter the width of the river: ");
scanf("%lf", &H);
printf("Enter v(0): ");
scanf("%lf", &vo);
printf("Enter the velocity of the boat in still water: ");
scanf("%lf", &V);
}
code code code code
Could someone please point me in the right direction? Probably using pretty basic coding language since I'm too 'newb' to understand complicated coding language.