Newton-Raphson method in C
2 posters
IITDU Forum :: Academics (BIT) :: Semester 3 :: MATH 304
Page 1 of 1
Newton-Raphson method in C
Hi guys,
I have implemented newton-raphson method in C. I am giving the code here for all of you.
If you find any problem you can post here.
I have implemented newton-raphson method in C. I am giving the code here for all of you.
- Code:
#include<stdio.h>
#include<math.h>
#define e .00001
#define F(x) (x)*(x)-3*(x)+2
#define Fd(x) 2*(x)-3
int main(void){
float x1,x2,f,fd,root;
x1=2.333;
f=F(x1);
fd=Fd(x1);
again:
printf("x1: %f\t",x1);
x2 = x1-(f/fd);
printf("x2: %f\n",x2);
if(fabs(x2-x1)>e){
x1=x2;
f=F(x1);
fd=Fd(x1);
goto again;
}else root = x2;
printf("The root is: %f\n",root);
float equvalue = F(root);
printf("Value of F(root) is: %f",equvalue);
return 0;
}
If you find any problem you can post here.
BIT0216-Habib- Administrator-RC
- Course(s) :
- BIT
Blood Group : O+
Posts : 217
Points : 458
Re: Newton-Raphson method in C
good work You can also check out this topic we made when we were in your stage.
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]
Similar topics
» Jaccobi Iteration Method in C
» Java Main Method
» Finding area of regions: Trapizoid and Simpson method
» printf method in Java
» Write a Swap method in Java
» Java Main Method
» Finding area of regions: Trapizoid and Simpson method
» printf method in Java
» Write a Swap method in Java
IITDU Forum :: Academics (BIT) :: Semester 3 :: MATH 304
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Tue Sep 29, 2015 2:45 pm by Sophiawood
» Cisco EHWIC SFP/GE WAN Card
Mon Sep 07, 2015 11:08 am by Sophiawood
» Huawei S1700-28GFR-4P-AC Price
Thu Jun 25, 2015 2:31 pm by Sophiawood
» teach yourself C++ / Herbert Schildt Solutions
Wed Jun 03, 2015 1:52 pm by Abdullah Al Noman
» teach yourself c by herbert schildt pdf
Wed May 13, 2015 11:01 pm by Raquib Ridwan
» ASA 5506X With Firepower ASA5506-K9
Fri Apr 10, 2015 4:31 pm by Sophiawood
» New Trends in Deal Business
Tue Feb 03, 2015 9:38 pm by nersoa
» PoE Power Allocation for WS-C2960S-24PS-L
Wed Nov 05, 2014 11:12 am by Sophiawood
» How to cure back pain
Fri Oct 31, 2014 7:15 pm by Bergen Guildford