clear
a=input('a=');
b=input('b=');
e=input('c=');
c=(a+b)/2
n=log2((b-a)/e)-1
if f(a)*f(b)>0
Solution='May be No Solution'
else
if f(c)==0
Solution=c
else
for i=1:1:n
c=(a+b)/2
if f(c)<0
a=c
else
b=c
end
end
Solution=c
end
end
a=input('a=');
b=input('b=');
e=input('c=');
c=(a+b)/2
n=log2((b-a)/e)-1
if f(a)*f(b)>0
Solution='May be No Solution'
else
if f(c)==0
Solution=c
else
for i=1:1:n
c=(a+b)/2
if f(c)<0
a=c
else
b=c
end
end
Solution=c
end
end
本文介绍了一种使用二分查找法求解特定数学问题的算法实现过程。通过输入变量a、b、c来逐步逼近解决方案,该算法适用于解决在有序区间内寻找特定值的问题。
6161

被折叠的 条评论
为什么被折叠?



