Hi there!

I was set to find minimum value of the function (y) wlile argument (x) is 0.3<=x<=3.3. However, my program says that minimum value is 2.255976 and the argument is 3.500000! You see, it can't be the right answer.

I'm giving the code below. If you see any mistake, tell me please. Thank you in advance and have a nice day!

#define A 13.8

#define B 1.26

#define X1 0.3

#define X2 3.3

#define DX 0.25

int main(void)

{

float x, y, ymin, xmin;

y=(A*sin(X1))/(sqrt(X1)+B);

ymin=y;

for(x=0.3;x<=3.3;x+=0.25) {

y=(A*sin(x))/(sqrt(x)+B);

if(y<ymin){

y=ymin;

x=xmin;

}

}

printf("Найменше значення функції=%f і відповідне їй значення аргумента=%f\t", ymin, xmin);

return 0;

}

Concerning initialising the variables, I have edited this code, but it doesn't work at all. I used the other compiler codepad, but the code doesn't work at all. This is my new code:

#include <stdio.h>

#include <math.h>

#define A 13.8

#define B 1.26

#define X1 0.3

#define X2 3.3

#define DX 0.25

int main(void)

{

float x, y, ymin, xmin;

y=(A*sin(X1))/(sqrt(X1)+B);

ymin=y;

xmin=X1;

for(x=0.3;x<=3.3;x+=0.25) {

y=(A*sin(x))/(sqrt(x)+B);

if(y<ymin){

y=ymin;

x=xmin;

}

}

printf("Найменше значення функції=%f і відповідне їй значення аргумента=%f\t", ymin, xmin);

return 0;

}

And this what the CodePad compiler says to me:

In function `main':

undefined reference to `sin'

undefined reference to `sin'.

Tell me please what to do if you know. Thanks again and have a nice day)