| 查看: 744 | 回复: 0 | ||
engine9817铜虫 (小有名气)
|
[求助]
求设计一个被积分函数中需要解方程的积分程序
|
|
如果有一个被积方程为G(x,y),积分区间假设为(1,2) 其中y的值与x是由另一个函数决定如f(x,y)=0; 这个式子不能直接得到y的解析式,复杂点的话,可能一个x有多个y值,但只有一个合适,如正的或实的。 这样在求积G(x,y)时,对应于每个x都要求解一个y值,还可能要对y值进行筛选。 我一开始在function文件里面设计了G(x,y)的程序.方便起见,我们假设 f(x,y)=x-y^2=0; 假设这里把y解析表示,要求用fsolve解出y function integrandfun=G(x) y=fsolve(@(t) x-t.^2, 1); integrandfun=x.^2+y; 主函数中调用 这个方程积分如 In=quadgk(@(x) integrandfun, 0,1); 结果是: 3.558078204809361与直接积分x.^2+sqrt(x)的结果3.552284749830793有差别 提示: 警告: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithm instead. > In fsolve at 285 In fkk at 3 In @(x)fkk(x) In quadgk>evalFun at 330 In quadgk>f1 at 348 In quadgk>vadapt at 249 In quadgk at 188 In figures at 12 No solution found. fsolve stopped because the last step was ineffective. However, the vector of function values is not near zero, as measured by the default value of the function tolerance. <stopping criteria details> 请问有进一步的优化吗?事实上如果把f(x,y)变得复杂点,积分存在更多问题。 |
» 猜你喜欢
各位基础老师们,看完中央《从严治党》的决定后,对学术界更加有信心了吧
已经有5人回复
【长期招聘】复旦大学 AI 制药实验室 博士后招聘
已经有12人回复
2027博士申请-临床检验诊断学、病原生物学、微生物方向
已经有5人回复










回复此楼