Regular Falsi

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Regular Falsi as PDF for free.

More details

  • Words: 119
  • Pages: 2
#include<stdio.h> #include #include<math.h> float f(float x) { return(sin(x)-x+2); } void main() { float x1,x2,x3,y1,y2,y3,acc; int i,n; clrscr(); printf("\n enter the value of initial guess x1="); scanf("%f", &x1); printf("\n enter the value of another guess x2="); scanf("%f", &x2); printf("\n enter the number of iterations ="); scanf("%d", &n); y1=f(x1); y2=f(x2); while(y1*y2>0) { printf("\n enter the value of x1 again ="); scanf("%f", &x1); printf("\n enter value of x2 again ="); scanf("%f", &x2); y1=f(x1); y2=f(x2); } for(i=1;i<=n;i++) { x3=(((x2*y1)-(x1*y2))/(y1-y2)); y3=f(x3); if(y1*y3<0) { x2=x3; y2=y3; } else

{ x1=x3; y1=y3; } } printf("\n the root x3=%f", x3); getch(); }

OUTPUT Enter the value of initial guess x1=2 Enter the value of initial guess x2=3 Enter the number of iterations =5 The root x3 =2.554196

Related Documents

Regular Falsi
June 2020 9
Regular Falsi
June 2020 4
Regular
October 2019 19
Regular
May 2020 14