Declaring a function

I want to define the following function:

f(x)= sin(a*x/(1+x^2))*atan(bx)+atan(x)

where a,b are constant parameters (e.g 3,2)


1
2
3
4
5
6
7
8
9
10
11
12
  #include <iostream>
#include <math.h>

using namespace std;

//Define function f(x)
double f(int a, int b, double x)
{
	double r
		r=sin((a*x)/(1+x*x))*atan(b*x)+atan(x)
	return r
}


would this work?

Thank you.
Last edited on
Why dont you try compiling it?
I can see missing semi-colon in various places
Compiling it to be sure is your best bet, but yes, this looks like it should work (aside from the missing semi-colons)

also beware to compile with the -lm command since you're using math.h
Topic archived. No new replies allowed.