blob: 54e52176249206c2118f1c2c27c7ff22fd764e32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// The equation 1/x-7==0 has a real root.
// the graph of this function can be observed here.
xset('window',13);
x=0.001:.001:.25; // defining the range of x.
deff('[y]=f(x)','y=1/x-7'); //defining the function.
deff('[y]=fp(x)','y=-1/x^2');
y=feval(x,f);
a=gca();
a.y_location = "origin";
a.x_location = "origin";
plot(x,y) // instruction to plot the graph
title(' y =1/x-7')
// from the above plot we can infre that the function has roots between
// the interval (0,2/7)
//solution by chebyshev method
chebyshev(0.1,f,fp) //calling the pre-defined function 'chebyshev' to find the approximate root in the range of (0,2/7).
|