| | |
help on finding root using newton raphon method
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2007
Posts: 3
Reputation:
Solved Threads: 0
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...
i dont know if i am starting the program right.. i need help on how to start the program
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...
C++ Syntax (Toggle Plain Text)
#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
Last edited by Narue; Oct 14th, 2008 at 4:05 pm. Reason: added code tags
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
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
Last edited by Freaky_Chris; Oct 14th, 2008 at 5:02 pm.
Knowledge is power -- But experience is everything
![]() |
Other Threads in the C++ Forum
- Previous Thread: date and time formats
- Next Thread: C++...
| Thread Tools | Search this Thread |
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game generator givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





