当前位置:网站首页>Matlab dichotomy to find the optimal solution
Matlab dichotomy to find the optimal solution
2022-07-03 09:16:00 【Fingering 13】
MATLAB Dichotomy to find the optimal solution
【 Vegetable dog bb】emm… The principle is quite simple , There should be nothing you don't understand . Is to give a function f And interval [a,b] And accuracy esp, Take the derivative of the intermediate value of the interval , Less than 0 Just assign the intermediate value to a, Greater than 0 Just assign the intermediate value to b. If the derivative equals 0 perhaps b-a The value is less than esp No longer judge , The intermediate value is the abscissa of the optimal solution .
No grinding , Look at the code or :
Here are some .
function [k,y]=erfenfa1(f,a,b,esp)
syms x;
% f Is the function given a,b For the given interval ,eps For accuracy
% Return value [k,y] Is the horizontal and vertical coordinates of the optimal solution
while b-a > esp
% Find out in a,b The derivative of the intermediate point
zhong = (b+a)/2;
dao = subs(diff(f),x,zhong);
% If the reciprocal is 0, be a,b In the middle zhong Is the abscissa of the optimal solution
if dao == 0
k=zhong;
y = subs(f,x,zhong);
break;
else
% The derivative is less than 0 take zhong Assign a value to a, Greater than 0 Assign to b
if(dao<0)
a = zhong;
else
b = zhong;
end
end
% When b-a Less than esp when , take a,b The midpoint is the abscissa of the optimal solution ,y Vertical coordinates
if b-a<=esp
k =(b+a)/2;
y = subs(f,x,k);
end
end
emm… Look at a simple test case :
>> clear
>> syms x;
f = x^2 + 2*x -1;
[x,y] = erfenfa1(f,-2,0,0.1);
>> [x,y]
ans =
[ -1, -2]
emm… One more piece ,,, Give me a compliment and I'll show you again , how ..( Manually cheat like )
Bye-bye , Hey .
边栏推荐
- Digital management medium + low code, jnpf opens a new engine for enterprise digital transformation
- 推荐一个 yyds 的低代码开源项目
- Instant messaging IM is the countercurrent of the progress of the times? See what jnpf says
- In the digital transformation, what problems will occur in enterprise equipment management? Jnpf may be the "optimal solution"
- Method of intercepting string in shell
- [point cloud processing paper crazy reading classic version 14] - dynamic graph CNN for learning on point clouds
- Use the interface colmap interface of openmvs to generate the pose file required by openmvs mvs
- [point cloud processing paper crazy reading frontier version 10] - mvtn: multi view transformation network for 3D shape recognition
- LeetCode 715. Range module
- Liteide is easy to use
猜你喜欢

AcWing 788. Number of pairs in reverse order

LeetCode 513. 找树左下角的值

【点云处理之论文狂读经典版10】—— PointCNN: Convolution On X-Transformed Points

即时通讯IM,是时代进步的逆流?看看JNPF怎么说

Excel is not as good as jnpf form for 3 minutes in an hour. Leaders must praise it when making reports like this!

2022-2-14 learning xiangniuke project - generate verification code

Low code momentum, this information management system development artifact, you deserve it!

Save the drama shortage, programmers' favorite high-score American drama TOP10

Jenkins learning (II) -- setting up Chinese

传统企业数字化转型需要经过哪几个阶段?
随机推荐
低代码前景可期,JNPF灵活易用,用智能定义新型办公模式
[point cloud processing paper crazy reading cutting-edge version 12] - adaptive graph revolution for point cloud analysis
Methods of checking ports according to processes and checking processes according to ports
[point cloud processing paper crazy reading classic version 14] - dynamic graph CNN for learning on point clouds
Data mining 2021-4-27 class notes
[point cloud processing paper crazy reading classic version 8] - o-cnn: octree based revolutionary neural networks for 3D shape analysis
LeetCode 513. 找树左下角的值
C language programming specification
Low code momentum, this information management system development artifact, you deserve it!
Internet Protocol learning record
数字化转型中,企业设备管理会出现什么问题?JNPF或将是“最优解”
【点云处理之论文狂读前沿版13】—— GAPNet: Graph Attention based Point Neural Network for Exploiting Local Feature
LeetCode 438. 找到字符串中所有字母异位词
我們有個共同的名字,XX工
数字化管理中台+低代码,JNPF开启企业数字化转型的新引擎
LeetCode 1089. 复写零
Basic knowledge of network security
AcWing 788. 逆序对的数量
Digital statistics DP acwing 338 Counting problem
LeetCode 532. 数组中的 k-diff 数对