#include
#include
#include
#define fn(x) (x*x*x-3*x*x-x+9)
void main()
{
clrscr();
float x,a,b,y,y1,y2;
cout<<"enter the initial value a&b"<
cin>>a>>b;
y1=fn(a);
y2=fn(b);
if(y1*y2>0)
{
cout<<"invalid interval"<
}
do
{
x=(a+b)/2;
y=fn(x);
if(y1*y<0)
{
b=x;
y2=y;
}
else
{
a=x;
y1=y;
}
}
while(fabs(b-a)>.001);
cout<<"the root of the equation ="<
getch();
}
Sep 3 '06 #4
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<iostream.h>
void main()
{
float a,b,c,x1,x2,disc;
clrscr();
printf("Enter the co-efficients\n");
scanf("%f%f%f",&a,&b,&c);
disc=b*b-4*a*c;
if(disc>0)
{
x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
printf("The roots are distinct\n");
}
if(disc==0)
{
x1=x2=-b/(2*a);
printf("The roots are equal\n");
printf("x1=%f\nx2=%f\n",x1,x2);
}
else
x1=-b/(2*a);
x2=sqrt(fabs(disc))/(2*a);
printf("The roots are complex\n");
printf("The first root=%f+i%f\n",x1,x2);
printf("The second root=%f-i%f\n",x1,x2);
getch();
}
main()
{
float a,b,c,x1,x2,x,series;
double d;
printf("enter a,b,c and x1(pos) & x2(neg)");
scanf("%f%f%f%f%f", &a, &b, &c, &x1, &x2);
read:
x = (x1 + x2) / 2;
series = a * x * x + b * x + c;
d = fabs(series);
if (d > 0.0001)
{
if (x * x1 < 0)
x = x2;
else
x = x1;
goto read;
}
else
{
printf("ans=%f", x);
}
return 0;
}
there are three variable are to find but in newton only one variable is taken at a time of a single iteration
An improved root finding scheme is to combine the bisection and Newton-Raphson methods. The bisection method guarantees a root (or singularity) and is used to limit the changes in position estimated by the Newton-Raphson method when the linear assumption is poor. However, Newton-Raphson steps are taken in the nearly linear regime to speed convergence. In other words, if we know that we have a root bracketed between our two bounding points, we first consider the Newton-Raphson step. If that would predict a next point that is outside of our bracketed range, then we do a bisection step instead by choosing the midpoint of the range to be the next point. We then evaluate the function at the next point and, depending on the sign of that evaluation, replace one of the bounding points with the new point. This keeps the root bracketed, while allowing us to benefit from the speed of Newton-Raphson.
write a vb program to find the magic square
Write a program to find the grade obtained by the students of a class
for two positive integers: public static int gcd(int i1, int i2) { // using Euclid's algorithm int a=i1, b=i2, temp; while (b!=0) { temp=b; b=a%temp; a=temp; } return a; }
I'm not familiar with the "bisection method" to find the roots of 2x2-5x+1 = 0 but by completing the square or using the quadratic equation formula you'll find that the solution is: x = (5 + or - the square root of 17) over 4 Hope that helps.
If this is in the context of finding a root of an equation, the answer is to make some guesses. Find value x1 and x2 such that f(x1) and f(x2) have opposite signs. Then, provided that f is a continuous function over (x1, x2), the bisection method will find its root.
there are three variable are to find but in newton only one variable is taken at a time of a single iteration
i need this answer
An improved root finding scheme is to combine the bisection and Newton-Raphson methods. The bisection method guarantees a root (or singularity) and is used to limit the changes in position estimated by the Newton-Raphson method when the linear assumption is poor. However, Newton-Raphson steps are taken in the nearly linear regime to speed convergence. In other words, if we know that we have a root bracketed between our two bounding points, we first consider the Newton-Raphson step. If that would predict a next point that is outside of our bracketed range, then we do a bisection step instead by choosing the midpoint of the range to be the next point. We then evaluate the function at the next point and, depending on the sign of that evaluation, replace one of the bounding points with the new point. This keeps the root bracketed, while allowing us to benefit from the speed of Newton-Raphson.
program to find maximum of two numbers using pointers
I usually find them on E-bay. It is cheaper this way. Then you just program it using the method in the owners manual. Good luck.
You can use the Math.sqrt() method.
Displacement method.... Is the method to find volume of an irregular object
We can find it by using wheatstone bridge.
write a vb program to find the magic square
using water displacement method