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

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - 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 值。