-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cuberoot.m
82 lines (79 loc) · 1.14 KB
/
Cuberoot.m
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
tic
format long g
f = []
i = 1
k = []
%x = vpa(pi)
for x=1.0:+0.100000:2.0
y = x.^3+4.*x.^2-10
g = toc
f(i) = y
k(i) = g
i = i+1
if(y>0)
x = x-0.1
break
end
end
y1 = x
for x = y1:+0.01:(y1+0.1)
y = x.^3 + 4.*x.^2 - 10
g = toc
f(i) = y
k(i) = g
i = i+1
if(y>0)
x = x-0.01
break
end
end
y1 = x
for x = y1:+0.001:(y1+0.01)
y = x.^3 + 4.*x.^2 - 10
g = toc
f(i) = y
k(i) = g
i = i+1
if(y>0)
x = x-0.001
break
end
end
y1 = x
for x = y1:+0.0001:(y1+0.001)
y = x.^3 + 4.*x.^2 - 10
g = toc
f(i) = y
k(i) = g
i = i+1
if(y>0)
x = x-0.0001
break
end
end
y1 = x
for x = y1:+0.00001:(y1+0.0001)
y = x.^3 + 4.*x.^2 - 10
g = toc
f(i) = y
k(i) = g
i = i+1
if(y>0)
x = x-0.00001
break
end
end
y1 = x
for x = y1:+0.000001:(y1+0.00001)
y = x.^3 + 4.*x.^2 - 10
g = toc
f(i) = y
k(i) = g
i = i+1
if(y>0)
x = x-0.000001
break
end
end
plot(f,k)
toc