#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float f(float x);
float df(float x);


int main(){
float x=-0.7;
int i=0;
float y;
do{
  printf("f(x) is %f",f(x));
  y=x-(f(x)/df(x));
  x=y;
  i=i+1;
  printf("repeats %d",i);
  printf("x is %f",x);
  
}while (f(x)!=0);
return(0);}
float f(float x)
{
        return (x+pow(exp,-10.0*pow(x,2.0))*cos(x));
}
float df(x)
{

        return ((1-20*x*exp^(-10*(x)^2)*cos(x)-exp^(-10*(x)^2)*sin(x)));
}

Recommended Answers

All 2 Replies

What's the problem? You realize that we can't read your mind and you need to tell us what you're having trouble with, right?

(((1-20*x*exp^(-10*(x)^2)*cos(x))-(exp^(-10*(x)^2)*sin(x))))

)
check your paranthesis

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.