| 查看: 704 | 回复: 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)变得复杂点,积分存在更多问题。 |
» 猜你喜欢
上海工程技术大学 激光智能制造课题组 2027级博士研究生招生
已经有5人回复
课题组招2027级博士 上海工程技术大学 激光智能制造方向
已经有5人回复
有机合成以后会不会被AI改变?做科研的虫友怎么看
已经有8人回复
求合成方法
已经有7人回复
现代”学阀”该如何界定
已经有12人回复
我的奶奶
已经有3人回复










回复此楼