云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 信息与计算科学专业实习报告

信息与计算科学专业实习报告

  • 62 次阅读
  • 3 次下载
  • 2025/6/1 3:05:15

信息与计算科学专业 专业实习报告

附录

function [x,fx,xflag]=find_roots1(f,c1,c2,rel_err) % f is the name of the function to be solved

% c1,c2 are the min and max bounds of x respectively % rel_err is the relative error,that is abs(f1n-f2n)/abs(f1-f2) % where f1n, f2n are the function values at the c1n and c2n % f1n, f2n are the function values at c1 and c2 % xflag is -1 if there's no root in range (c1,c2) % xflag equals to 1 if there is a root in range (c1,c2) % x is the root solved % fx is its value % example

% [x,fx,xflag]=find_roots1(@sin,0.1,pi+0.1,1e-6) %{ c1=0.01; c2=pi+0.1; rel_err=1e-3; f=@sin; %} xflag=-1; f1=feval_r(f,c1); f2=feval_r(f,c2); abs_f1_2=abs(f1-f2); if abs(f1) <= rel_err*abs_f1_2 x=c1; fx=f1; xflag=1; return;

elseif abs(f2) <= rel_err*abs_f1_2 x=c2; fx=f2; xflag=1; return;

21

信息与计算科学专业 专业实习报告

elseif f1*f2 >0 x=nan; fx=nan; return; else for i1=1:100 c0=(c1+c2)/2; f0=feval_r(f,c0);

if abs(f0) <= rel_err*abs_f1_2 x=c0; fx=f0; xflag=1; return; elseif f1*f0 >0 c1=c0; f1=f0; else c2=c0; f2=f0; end

if abs(f1-f2)

elseif abs(f1-f2)>100*abs_f1_2 xflag=-1; x=nan; fx=nan; return; end end end

22

搜索更多关于: 信息与计算科学专业实习报告 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

信息与计算科学专业 专业实习报告 附录 function [x,fx,xflag]=find_roots1(f,c1,c2,rel_err) % f is the name of the function to be solved % c1,c2 are the min and max bounds of x respectively % rel_err is the relative error,that is abs(f1n-f2n)/abs(f1-f2) % where f1n, f2n are the function values at the c1n and c2n % f1n, f2n are the function values at c1 and c2 % xflag is -1 if there's no root i

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com