You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于调和均值的log10(x+1)近似:如何优化参数a、b、c?

优化log₁₀(x+1)近似函数的参数求解问题

现有近似函数

当 (x+1 < \sim1.2)(即 (x \in (0, 0.2]))时,用于近似计算 (\log_{10}(x+1)) 的函数实现如下:

a = 1.097
b = 0.085
c = 2.31

ans = 1 / (a - b*x + c/x)

对应的数学表达式:
近似函数数学形式

该方法通过调整调和均值拟合log₁₀函数,但参数a、b、c的最优取值尚未确定。

核心问题

  • 如何获取a、b、c的最优参数值?
  • 如何提升该近似函数的计算精度?

当前实现的局限

我采用类似神经网络反向传播的思路编写了参数求解代码,但无法进一步提升精度:

import numpy as np

a = 1
b = 0.01
c = 2

def mlg(t):
    x = t
    if t == 0:
        x = 0.00000001
    x2 = x*x
    o = a - (b * x) + (c / x)
    return 1/o

def mlg0(t):
    x = t
    if t == 0:
        x = 0.00000001
    x2 = x*x
    o = a - (b * x) + (c / x)
    return o

for i in range(9000):
    n1 = np.random.uniform(0,1.19,1000)
    for i in range(1000):
        n = n1[i]
        o = np.log10(n+1)
        u = mlg(n) - o
        e = u ** 2

        de_da = 0 - 2 * (u) / (mlg0(n) ** 2)
        de_db = de_da * n 
        de_dc = de_da / n

        a -= de_da * 0.00001
        b -= de_db * 0.00001
        c -= de_dc * 0.00001

print(a,b,c)

误差计算方式如下:
误差计算表达式

请问如何修改上述代码以生成更优的参数值?

内容的提问来源于stack exchange,提问作者luaenjoyer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 06:25:11