License Public Domain
Lines 33
Average
n/a
Rated
0
Times
5
4
3
2
1
0
Keywords
finding zeros (2) numerical analysis (5)
Permissions
Owner: David
Viewable by Everyone
Editable by All Siafoo Users
Hide
Bored? Check out the Recent Activity on Siafoo Join Siafoo Now or Learn More

Fixed Point Iteration Atom Feed

In Brief Find zeros of a function near a given point.
# 's
 1/*
2 By David Isaacson, 2003
3 Released into the Public Domain
4
5 fixedpt.c
6
7 The puropse of this program is to find the zero near x=1 of
8 f(x)=2x^3+4x^2-2x-5=0
9
10this can be rearranged into x=g(x)=(-1/13)(2x^3+4x^2-15x-5)
11 */
12
13#include <stdio.h>
14#include <math.h>
15
16int main()
17{
18 float x; //the start coord
19 float xnew; //the end coord
20
21 printf("Hello\n");
22
23 printf("What value shall we start at? ");
24 scanf("%f",&xnew);
25
26 do
27 {
28 x=xnew;
29 xnew=(2*x*x*x+4*x*x-15*x-5)/-13;//x=g(x)
30 }while(x!=xnew); //again going to the max of the software
31
32 printf("The graphs intersect at %.3f \n",xnew);
33 //this prints xnew to a precision of 3 decimal places
34
35 return 0;
36}
37
38/*
39 When I ran this on my computer, I recieved the result:
40
41 Hello
42 What value shall we start at? 1
43 The graphs intersect at 1.078
44
45 */

Find zeros of a function near a given point.