- 注册时间
- 2018-4-16
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 1865
- 在线时间
- 小时
|
楼主 |
发表于 2025-5-21 18:56:40
|
显示全部楼层
本帖最后由 笨笨 于 2025-5-21 19:17 编辑
折腾了2天未果!下面的程序deepseek算的结果很接近主贴所求m值。
最优参数 m = 46.4295,误差=0.00001868207537802924,b=0.05376700730325596
检验误差:
- NumberForm[
- N[NMaximize[{Abs[
- Hypergeometric2F1[-(1/2), -(1/2),
- 1, ((1 - b)/(
- 1 + b))^2] - (1 + (3 ((1 - b)/(1 + b))^2)/(
- 10 + Sqrt[
- 4 - 3 ((1 - b)/(1 + b))^2])) (1 + (22/(7 \[Pi]) - 1) (1 -
- b)^ 46.42947629474779` )], 0 < b < 1}, b]], 10]
复制代码
求出最优m值
- (*左边 Hypergeometric 函数*)
- left[x_] := Hypergeometric2F1[-1/2, -1/2, 1, ((1 - x)/(1 + x))^2];
- (*右边修正后的表达式*)
- right[x_,
- m_] := (1 + (3*((1 - x)/(1 + x))^2)/(10 +
- Sqrt[4 - 3*((1 - x)/(1 + x))^2]))*(1 + (22/(7*Pi) -
- 1)*(1 - x)^m);
- (*预计算常数项优化计算效率*)
- constantFactor = N[22/(7*Pi) - 1];(* \[TildeTilde]-0.31831*)
- right[x_?NumericQ,
- m_?NumericQ] := (1 + (3*((1 - x)/(1 + x))^2)/(10 +
- Sqrt[4 - 3*((1 - x)/(1 + x))^2]))*(1 +
- constantFactor*(1 - x)^m);
- (*定义均方误差,积分区间设为[0,1]*)
- mse[m_?NumericQ] :=
- NIntegrate[(left[x] - right[x, m])^2, {x, 0, 1},
- Method -> "GlobalAdaptive", MaxRecursion -> 20];
- (*全局优化,限制 m>0*)
- result = NMinimize[{mse[m], m > 0}, m, Method -> "SimulatedAnnealing"];
- {minError, {mOpt -> mValue}} = result;
- (*输出结果*)
- Print["最优参数 m = ", mOpt, ",最小均方误差 = ", minError]
- (*绘制函数对比*)optM = mOpt /. result[[2]];
- Plot[{left[x], right[x, optM]}, {x, 0, 1},
- PlotLegends -> {"Hypergeometric", "Approximation"},
- PlotStyle -> {Blue, Red}, Frame -> True,
- FrameLabel -> {"x", "Function Value"},
- PlotLabel -> "Optimal m = " <> ToString[optM]]
复制代码 |
|