i have this function f(x)= e^X-3X^2
I need to write a computer program that find all three roots by the use of newton raphson method and option of finding a root by use of fixed point iteration.

this is all i came up with so far..
i need help...

#include <iostream.h>
#include<iomanip>
#include<math.h>

using namespace std;

//(&f) (x) reference to function f(x)//
//(fdiv)(x) reference to function f'(x)//
double x;
double func_1;
doublefdiv_1;

//............................................................//
//test function

double func_1(double x)
{
return (e^x-3x^2);
//f(x)=e^x-3x^2=0
}
double fdiv_1(double x)
{
return (e^x-6x);
// f'(x)=e^x-6x

i dont know if i am starting the program right.. i need help on how to start the program

Hmmm. I don't think that the ^ operator works in c++. I could be wrong =\ , but I think you must use the POW func in the cmath header. I think that ^ is some sort of bitwise XOR or XNOR or something of the sort.

I have no idea what that method of finding roots is, perhaps explain in detail what you need to do and I can help translate it into c++ code.

indeed, you must use the cmath header...

pow() and also sqrt() will find the square root of a number xD

pow takes to aruments first is the number to be raised to the powerof the second number if that makes sense.

Also i should talk about the chain rule.

the chain rule can be used to find the derivative of (ax+b)^z in a few simple steps.
It also applies to finding the derivative of e^(x-3x^2) in your case

the chain rule is this

dy/dx = du/dx * dy/du

now where does you come into well we set the power of e = u so

e^(x-3x^2) becomes
u = x-3x^2

therefore, we get this

f(x) = e^u therefore dy/du = e^u.

but we must find the derivative of u

u = x-3x^2
du/dx = x-6x

so back to the chain rule.

dy/dx = du/dx * dy/du

dy/dx = (x-6x) * (e^u)

dy/dx = (x-6x)(e^(x-3x^2))

Hope that helps you with finding the correct derivative.

Chris

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.