惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
D
Docker
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
美团技术团队
V
V2EX
Last Week in AI
Last Week in AI
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Microsoft Security Blog
Microsoft Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
人人都是产品经理
人人都是产品经理
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
B
Blog RSS Feed
博客园_首页
B
Blog
博客园 - 叶小钗
I
InfoQ
WordPress大学
WordPress大学
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
About on SuperTechFans
The GitHub Blog
The GitHub Blog
The Register - Security
The Register - Security
MyScale Blog
MyScale Blog
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
Latest news
Latest news
W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
C
CXSECURITY Database RSS Feed - CXSecurity.com
Recent Commits to openclaw:main
Recent Commits to openclaw:main
N
News and Events Feed by Topic
S
Secure Thoughts
The Hacker News
The Hacker News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News

博客园 - CalvinChu

vyos syslog配置 How to upgrade pip on Debian Wheezy OpenWRT and VPN Passthrough - CalvinChu 如何将 find 命令与 exec 一起使用 CentOS 7 下搭建 OpenVPN - CalvinChu How to get the ip ranges of domain esxi 直通sata控制器 Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_P xRDP – Detected issues with Debian 11 – Oh No ! Something has gone wrong…. qemu-mips环境搭建跳坑指南 ImportError: libSM.so.6: cannot open shared object file: No such file or directory openwrt(lede)中,PPtP Client需要安装的软件包 OpenWrt中的Hotplug脚本 MAC OSX VPN自动添加静态路由 - CalvinChu fbprophet安装和使用 CentOS7安装iptables防火墙 CENTOS7下安装REDIS mysql忘记root密码解决办法 iptables命令(备忘)
指数数据解密,懂的都懂
CalvinChu · 2024-01-04 · via 博客园 - CalvinChu

from scipy.optimize import fsolve
import numpy as np

#y = (10 ln(x+1)+30)x^0.5
def inverse_function(y_val):
"""
Approximate the inverse of the function y = (10 * ln(x + 1) + 30) * x**0.5.
This function takes a y value and returns the corresponding x value.
"""
# Define the function to solve
def equation(x):
return (10 * np.log(x + 1) + 30) * np.sqrt(x) - y_val

# Initial guess for x, can be adjusted based on the range of expected x values
initial_guess = 1

# Solve for x
x_val = fsolve(equation, initial_guess)

return x_val[0]

# Example usage 12,295 10119
y_example = 12295
x_result = inverse_function(y_example)
print(x_result)

function inverseFunction(y) {
    // Define the function y = (10 * ln(x + 1) + 30) * sqrt(x)
    function f(x) {
        return (10 * Math.log(x + 1) + 30) * Math.sqrt(x);
    }

    // Set the initial bounds for x
    let lowerBound = 0;
    let upperBound = 10000000; // You can adjust this upper bound as needed
    let x;
    let tolerance = 1e-5; // Tolerance for the approximation

    // Binary search to find the inverse
    while (upperBound - lowerBound > tolerance) {
        x = (lowerBound + upperBound) / 2;
        let yCalc = f(x);

        if (Math.abs(yCalc - y) < tolerance) {
            break;
        } else if (yCalc < y) {
            lowerBound = x;
        } else {
            upperBound = x;
        }
    }

    return x;
}

// Example usage 12295 10119
let y = 12295;
let x = inverseFunction(y);
console.log(`The value of x for y = ${y} is approximately: ${x}`);
Function InverseFunction(y As Double) As Double
    Dim x As Double
    Dim x0 As Double
    Dim diff As Double
    Const EPSILON As Double = 1E-06    ' 定义收敛精度
    Dim f As Double, df As Double
    
    x = 1 ' 初始猜测值
    Do
        x0 = x
        ' 计算当前x的函数值和导数值
        f = (10 * Log(x + 1) + 30) * Sqr(x) - y
        df = (10 / (x + 1) + 30 / (2 * Sqr(x))) * Sqr(x) + (10 * Log(x + 1) + 30) * 0.5 / Sqr(x)
        
        ' 使用牛顿-拉夫森方法更新x值
        x = x - f / df
        
        ' 检查是否已经足够接近
        diff = Abs(x - x0)
    Loop While diff > EPSILON
    
    InverseFunction = x
End Function

 在EXCEL中引用:

  1. 打开VBA编辑器:在Excel中,按下 Alt + F11 打开VBA编辑器。
  2. 插入一个模块:在VBA编辑器中,右击你的工作簿名字下的 "Microsoft Excel Objects",选择 "Insert" > "Module"。这会创建一个新的模块。
  3. 粘贴函数代码:将之前给出的 InverseFunction 函数代码复制并粘贴到新创建的模块中。
  4. 保存并关闭VBA编辑器:点击保存按钮(或按 Ctrl + S),然后关闭VBA编辑器。

一旦你完成了这些步骤,你就可以在任何Excel工作表中像调用Excel内置函数一样调用 InverseFunction 函数了。这里是如何操作的:

  • 直接在单元格中调用:点击你想要显示结果的单元格,输入公式 =InverseFunction(Y值),其中 Y值 是你希望用来求对应 XY 的值

  • 使用单元格引用:你也可以引用包含 Y 值的单元格。例如,如果单元格 A1 包含值 12295,则在另一个单元格中输入 =InverseFunction(A1) 将会返回相应的 X 值。