atanh() 函数用于计算反双曲正切值,返回参数的反双曲正切值。
atanh() 函数返回一个数的反双曲正切值(inverse hyperbolic tangent)。参数必须在 -1 到 1 之间(不包含端点),返回值是实数。
atanh(float $num): float
| 参数 | 类型 | 描述 | 必需 |
|---|---|---|---|
$num |
float | 要计算反双曲正切值的数字,必须在 -1 到 1 之间(不包含-1和1) | 是 |
返回参数 $num 的反双曲正切值,以浮点数形式返回。返回值满足:tanh(atanh(x)) = x。
计算不同数字的反双曲正切值:
<?php
// 计算反双曲正切值
echo "atanh(0) = " . atanh(0) . "\n"; // 0
echo "atanh(0.5) = " . atanh(0.5) . "\n"; // 约 0.54930614433405
echo "atanh(-0.5) = " . atanh(-0.5) . "\n"; // 约 -0.54930614433405
echo "atanh(0.9) = " . atanh(0.9) . "\n"; // 约 1.4722194895832
echo "atanh(-0.9) = " . atanh(-0.9) . "\n"; // 约 -1.4722194895832
echo "atanh(0.99) = " . atanh(0.99) . "\n"; // 约 2.6466524123622
echo "atanh(-0.99) = " . atanh(-0.99) . "\n"; // 约 -2.6466524123622
// 验证 tanh(atanh(x)) = x
$x = 0.75;
$atanh_x = atanh($x);
$tanh_atanh_x = tanh($atanh_x);
echo "验证: tanh(atanh($x)) = tanh($atanh_x) = $tanh_atanh_x\n";
echo "误差: " . abs($tanh_atanh_x - $x) . "\n";
// 处理接近边界的情况
echo "atanh(0.999) = " . atanh(0.999) . "\n"; // 约 3.8002011672502
echo "atanh(-0.999) = " . atanh(-0.999) . "\n"; // 约 -3.8002011672502
?>
验证双曲函数和反双曲函数的关系:
<?php
// 双曲函数关系验证
class HyperbolicFunctions {
// 计算反双曲正切的自然对数表示
public static function atanhByFormula($x) {
if ($x <= -1 || $x >= 1) {
throw new InvalidArgumentException("x 必须在 -1 和 1 之间");
}
return 0.5 * log((1 + $x) / (1 - $x));
}
// 验证 atanh(x) = 0.5 * ln((1+x)/(1-x))
public static function verifyAtanhFormula($x) {
$atanh_value = atanh($x);
$formula_value = self::atanhByFormula($x);
$difference = abs($atanh_value - $formula_value);
return [
'atanh' => $atanh_value,
'formula' => $formula_value,
'difference' => $difference,
'verified' => $difference < 1e-10
];
}
// 验证双曲函数性质
public static function verifyProperties($x) {
if ($x <= -1 || $x >= 1) {
throw new InvalidArgumentException("x 必须在 -1 和 1 之间");
}
$y = atanh($x);
// 性质1: tanh(atanh(x)) = x
$property1 = tanh($y);
// 性质2: atanh(tanh(y)) = y
$property2 = atanh(tanh($y));
// 性质3: 奇函数性质 atanh(-x) = -atanh(x)
$property3 = atanh(-$x);
// 性质4: 导数公式验证
$derivative = 1 / (1 - $x * $x);
return [
'x' => $x,
'y' => $y,
'tanh(y)' => tanh($y),
'property1_error' => abs($property1 - $x),
'atanh(tanh(y))' => $property2,
'property2_error' => abs($property2 - $y),
'atanh(-x)' => $property3,
'property3_error' => abs($property3 + $y),
'derivative' => $derivative
];
}
}
// 测试
echo "公式验证:\n";
$testValues = [0, 0.3, 0.6, -0.3, -0.6, 0.9, -0.9];
foreach ($testValues as $x) {
try {
$result = HyperbolicFunctions::verifyAtanhFormula($x);
echo "x = $x: atanh = " . round($result['atanh'], 6) .
", 公式 = " . round($result['formula'], 6) .
", 差异 = " . $result['difference'] .
", 验证" . ($result['verified'] ? "通过" : "失败") . "\n";
} catch (Exception $e) {
echo "x = $x: " . $e->getMessage() . "\n";
}
}
echo "\n双曲函数性质验证:\n";
foreach ([0, 0.5, -0.5, 0.8] as $x) {
try {
$props = HyperbolicFunctions::verifyProperties($x);
echo "x = $x, y = atanh(x) = " . round($props['y'], 4) . "\n";
echo " 验证 tanh(y) = x: tanh(" . round($props['y'], 4) . ") = " .
round($props['tanh(y)'], 4) . " (误差: " . round($props['property1_error'], 10) . ")\n";
echo " 验证 atanh(tanh(y)) = y: " . round($props['atanh(tanh(y))'], 4) .
" (误差: " . round($props['property2_error'], 10) . ")\n";
echo " 验证奇函数性质 atanh(-x) = -atanh(x): " . round($props['atanh(-x)'], 4) .
" = -" . round($props['y'], 4) . " (误差: " . round($props['property3_error'], 10) . ")\n";
echo " 导数: d(atanh(x))/dx = 1/(1-x²) = " . round($props['derivative'], 4) . "\n\n";
} catch (Exception $e) {
echo "x = $x: " . $e->getMessage() . "\n";
}
}
?>
在统计学和概率论中应用atanh()函数:
<?php
// Fisher Z变换(相关系数的变换)
class StatisticalTransforms {
// Fisher Z变换(用于相关系数的正态化)
public static function fisherZTransform($r) {
if ($r <= -1 || $r >= 1) {
throw new InvalidArgumentException("相关系数必须在 -1 和 1 之间");
}
return atanh($r); // 等价于 0.5 * ln((1+$r)/(1-$r))
}
// 反Fisher Z变换
public static function inverseFisherZTransform($z) {
return tanh($z);
}
// 计算相关系数的置信区间
public static function correlationConfidenceInterval($r, $n, $confidence = 0.95) {
// n: 样本大小
if ($n <= 3) {
throw new InvalidArgumentException("样本大小必须大于3");
}
// Fisher Z变换
$z = self::fisherZTransform($r);
// 标准误差
$se = 1 / sqrt($n - 3);
// Z分数(对于95%置信度,Z=1.96)
$z_score = 1.96; // 默认95%置信度
if ($confidence == 0.90) $z_score = 1.645;
if ($confidence == 0.99) $z_score = 2.576;
// 计算Z变换后的置信区间
$z_lower = $z - $z_score * $se;
$z_upper = $z + $z_score * $se;
// 反变换得到相关系数的置信区间
$r_lower = self::inverseFisherZTransform($z_lower);
$r_upper = self::inverseFisherZTransform($z_upper);
return [
'r' => $r,
'z' => $z,
'z_lower' => $z_lower,
'z_upper' => $z_upper,
'r_lower' => $r_lower,
'r_upper' => $r_upper,
'confidence' => $confidence * 100 . '%',
'sample_size' => $n
];
}
// 计算两个相关系数的差异显著性
public static function compareCorrelations($r1, $n1, $r2, $n2) {
$z1 = self::fisherZTransform($r1);
$z2 = self::fisherZTransform($r2);
// 计算Z统计量
$z_diff = ($z1 - $z2) / sqrt(1/($n1-3) + 1/($n2-3));
// 计算p值(双尾检验)
$p_value = 2 * (1 - self::normalCDF(abs($z_diff)));
return [
'z1' => $z1,
'z2' => $z2,
'z_diff' => $z_diff,
'p_value' => $p_value,
'significant' => $p_value < 0.05
];
}
// 标准正态分布累积分布函数(简化版)
private static function normalCDF($z) {
// 使用近似公式
$t = 1 / (1 + 0.2316419 * abs($z));
$d = 0.3989423 * exp(-$z * $z / 2);
$probability = 1 - $d * $t * (0.3193815 + $t * (-0.3565638 + $t * (1.781478 + $t * (-1.821256 + $t * 1.330274))));
return $z > 0 ? $probability : 1 - $probability;
}
}
// 使用示例
echo "Fisher Z变换(相关系数的正态化):\n";
$correlations = [0.1, 0.5, 0.8, -0.3, -0.7];
foreach ($correlations as $r) {
try {
$z = StatisticalTransforms::fisherZTransform($r);
$r_back = StatisticalTransforms::inverseFisherZTransform($z);
echo "r = " . str_pad($r, 5) . " → z = " . round($z, 4) .
" → 反变换 = " . round($r_back, 4) .
" (误差: " . abs($r - $r_back) . ")\n";
} catch (Exception $e) {
echo "r = $r: " . $e->getMessage() . "\n";
}
}
echo "\n相关系数的置信区间:\n";
$r = 0.6;
$n = 50;
$ci = StatisticalTransforms::correlationConfidenceInterval($r, $n);
echo "相关系数: r = $r, 样本大小: n = $n\n";
echo "Fisher Z变换: z = " . round($ci['z'], 4) . "\n";
echo "{$ci['confidence']} 置信区间:\n";
echo " Z变换区间: [" . round($ci['z_lower'], 4) . ", " . round($ci['z_upper'], 4) . "]\n";
echo " 相关系数区间: [" . round($ci['r_lower'], 4) . ", " . round($ci['r_upper'], 4) . "]\n";
echo "\n两个相关系数的比较:\n";
$r1 = 0.6; $n1 = 50;
$r2 = 0.4; $n2 = 60;
$comparison = StatisticalTransforms::compareCorrelations($r1, $n1, $r2, $n2);
echo "相关系数1: r1 = $r1, n1 = $n1\n";
echo "相关系数2: r2 = $r2, n2 = $n2\n";
echo "Z变换值: z1 = " . round($comparison['z1'], 4) . ", z2 = " . round($comparison['z2'], 4) . "\n";
echo "Z统计量: " . round($comparison['z_diff'], 4) . "\n";
echo "p值: " . round($comparison['p_value'], 4) . "\n";
echo "差异是否显著: " . ($comparison['significant'] ? "是 (p < 0.05)" : "否 (p >= 0.05)") . "\n";
// 在逻辑回归中的应用(链接函数)
echo "\n逻辑回归中的链接函数:\n";
class LogisticRegression {
// 使用atanh作为链接函数的变体
public static function atanhLink($p) {
// p 是概率,在 0 到 1 之间
if ($p <= 0 || $p >= 1) {
throw new InvalidArgumentException("概率必须在 0 和 1 之间");
}
// 将概率转换为 [-1, 1] 区间
$x = 2 * $p - 1;
return atanh($x);
}
// 反链接函数
public static function inverseAtanhLink($y) {
$x = tanh($y);
return ($x + 1) / 2;
}
// 标准逻辑函数(sigmoid)
public static function sigmoid($z) {
return 1 / (1 + exp(-$z));
}
}
// 比较不同链接函数
$probabilities = [0.1, 0.25, 0.5, 0.75, 0.9];
echo "概率 ↔ atanh链接函数:\n";
foreach ($probabilities as $p) {
try {
$y = LogisticRegression::atanhLink($p);
$p_back = LogisticRegression::inverseAtanhLink($y);
echo "p = $p → y = " . round($y, 4) . " → p' = " . round($p_back, 4) .
" (误差: " . abs($p - $p_back) . ")\n";
} catch (Exception $e) {
echo "p = $p: " . $e->getMessage() . "\n";
}
}
?>
处理atanh()函数的数值稳定性和边界情况:
<?php
// 安全的atanh函数,包含数值稳定性处理
class SafeHyperbolicInverse {
// 安全的atanh计算,处理数值稳定性
public static function safeAtanh($x) {
// 检查输入类型
if (!is_numeric($x)) {
throw new InvalidArgumentException("参数必须是数字");
}
// 处理特殊值
if (is_nan($x)) return NAN;
if (is_infinite($x)) {
// atanh(±∞) = NaN
return NAN;
}
// 检查边界条件
if ($x <= -1 || $x >= 1) {
// 如果非常接近边界(由于浮点误差)
$epsilon = 1e-15;
if (abs($x) - 1 < $epsilon && abs($x) - 1 >= 0) {
// 对于接近1的值,使用近似公式
if ($x > 0) {
return self::atanhNearOne($x);
} else {
return -self::atanhNearOne(-$x);
}
}
throw new RangeException("atanh() 参数必须在 -1 和 1 之间。输入值: " . $x);
}
// 特殊情况的精确值
if (abs($x) < 1e-10) {
// 对于接近0的值,使用泰勒展开提高精度
return self::atanhTaylor($x);
}
// 通用情况
return atanh($x);
}
// 对于接近1的值,使用近似公式
private static function atanhNearOne($x) {
// 使用公式: atanh(x) ≈ 0.5 * ln(2/(1-x)) - ln(2)/2 当 x→1⁻
// 或更简单的: atanh(x) ≈ 0.5 * ln(2/(1-x))
return 0.5 * log(2 / (1 - $x));
}
// 使用泰勒展开计算atanh(用于接近0的值提高精度)
private static function atanhTaylor($x, $terms = 10) {
$result = $x;
$x_power = $x;
for ($n = 1; $n < $terms; $n++) {
$x_power *= $x * $x;
$result += $x_power / (2 * $n + 1);
}
return $result;
}
// 批量计算并验证
public static function batchAtanh(array $values) {
$results = [];
foreach ($values as $index => $value) {
try {
$result = self::safeAtanh($value);
$verification = tanh($result);
$results[$index] = [
'input' => $value,
'result' => $result,
'tanh(result)' => $verification,
'error' => abs($verification - $value),
'status' => 'success'
];
} catch (Exception $e) {
$results[$index] = [
'input' => $value,
'result' => null,
'status' => 'error',
'message' => $e->getMessage()
];
}
}
return $results;
}
// 计算相对误差
public static function relativeError($exact, $approximate) {
if ($exact == 0) {
return abs($approximate);
}
return abs(($approximate - $exact) / $exact);
}
}
// 测试边界条件和特殊值
echo "测试边界条件和特殊值:\n";
$testCases = [
0, // 零
0.5, // 正常值
-0.5, // 负值
0.9999999999999999, // 非常接近1
-0.9999999999999999, // 非常接近-1
1.0000000000000001, // 略大于1
-1.0000000000000001, // 略小于-1
1, // 等于1
-1, // 等于-1
2, // 大于1
-2, // 小于-1
1e-20, // 非常小的正数
-1e-20, // 非常小的负数
"0.7", // 字符串数字
"abc", // 无效字符串
NAN, // NAN
INF, // 正无穷
-INF, // 负无穷
0.99, // 接近边界
0.9999 // 更接近边界
];
foreach ($testCases as $testValue) {
echo "输入: ";
if (is_nan($testValue)) {
echo "NAN";
} elseif (is_infinite($testValue)) {
echo $testValue > 0 ? "INF" : "-INF";
} else {
echo is_float($testValue) && abs($testValue) > 1e10 ?
sprintf("%.2e", $testValue) : $testValue;
}
echo " => ";
try {
$result = SafeHyperbolicInverse::safeAtanh($testValue);
if (is_nan($result)) {
echo "NAN";
} elseif (is_infinite($result)) {
echo $result > 0 ? "INF" : "-INF";
} else {
echo is_float($result) && abs($result) > 1e10 ?
sprintf("%.2e", $result) : round($result, 6);
// 验证
if (is_numeric($testValue) && $testValue > -1 && $testValue < 1) {
$verification = tanh($result);
$error = abs($verification - $testValue);
if ($error > 1e-10) {
echo " (验证失败,误差: " . sprintf("%.2e", $error) . ")";
}
}
}
} catch (Exception $e) {
echo "错误: " . $e->getMessage();
}
echo "\n";
}
echo "\n精度比较:\n";
$precisionTestValues = [-0.9999, -0.99, -0.9, -0.5, 0, 0.5, 0.9, 0.99, 0.9999];
foreach ($precisionTestValues as $value) {
$builtin = atanh($value);
$custom = SafeHyperbolicInverse::safeAtanh($value);
$rel_error = SafeHyperbolicInverse::relativeError($builtin, $custom);
echo "x = " . str_pad($value, 8) . ": 内置 = " . sprintf("%.10e", $builtin) .
", 自定义 = " . sprintf("%.10e", $custom) .
", 相对误差 = " . sprintf("%.2e", $rel_error) . "\n";
}
// 数值积分验证导数
echo "\n数值积分验证导数:\n";
function integrateDerivative($a, $b, $n = 1000) {
// 计算 ∫(1/(1-x²))dx 从 a 到 b
// 解析解: atanh(x)
$sum = 0;
$dx = ($b - $a) / $n;
for ($i = 0; $i < $n; $i++) {
$x = $a + ($i + 0.5) * $dx;
$sum += 1 / (1 - $x * $x);
}
return $sum * $dx;
}
$a = 0;
$b = 0.8;
$numerical = integrateDerivative($a, $b);
$exact = atanh($b) - atanh($a);
$error = abs($numerical - $exact);
echo "数值积分 ∫(1/(1-x²))dx 从 $a 到 $b:\n";
echo "数值结果: " . round($numerical, 6) . "\n";
echo "精确结果: " . round($exact, 6) . " (atanh($b) - atanh($a))\n";
echo "误差: " . sprintf("%.2e", $error) . "\n";
?>
在科学计算和工程中使用atanh()函数:
<?php
// 传输线计算(微波工程)
class TransmissionLine {
// 计算反射系数的相位
public static function reflectionPhase($gamma_real, $gamma_imag) {
// gamma 是复反射系数
$magnitude = sqrt($gamma_real * $gamma_real + $gamma_imag * $gamma_imag);
$phase_rad = atan2($gamma_imag, $gamma_real);
// 使用atanh计算其他参数
$z = $gamma_real + $gamma_imag * 1i; // 复数表示
return [
'magnitude' => $magnitude,
'phase_rad' => $phase_rad,
'phase_deg' => rad2deg($phase_rad),
'vswr' => (1 + $magnitude) / (1 - $magnitude), // 电压驻波比
'return_loss_db' => -20 * log10($magnitude) // 回波损耗
];
}
// 计算阻抗归一化
public static function normalizeImpedance($z_real, $z_imag, $z0 = 50) {
// z0: 特性阻抗(通常为50欧姆)
$z = ($z_real + $z_imag * 1i) / $z0;
$gamma = ($z - 1) / ($z + 1); // 反射系数
return [
'z_normalized' => $z,
'gamma' => $gamma,
'gamma_magnitude' => abs($gamma),
'gamma_phase_deg' => rad2deg(atan2(imag($gamma), real($gamma)))
];
}
}
// 使用示例
echo "传输线计算(微波工程):\n";
$gamma_real = 0.3;
$gamma_imag = 0.4;
$reflection = TransmissionLine::reflectionPhase($gamma_real, $gamma_imag);
echo "反射系数: Γ = $gamma_real + j$gamma_imag\n";
echo "反射系数幅度: |Γ| = " . round($reflection['magnitude'], 4) . "\n";
echo "反射系数相位: " . round($reflection['phase_deg'], 2) . "°\n";
echo "电压驻波比(VSWR): " . round($reflection['vswr'], 4) . "\n";
echo "回波损耗: " . round($reflection['return_loss_db'], 2) . " dB\n";
echo "\n阻抗归一化:\n";
$z_real = 75;
$z_imag = 25;
$normalized = TransmissionLine::normalizeImpedance($z_real, $z_imag);
echo "阻抗: Z = {$z_real} + j{$z_imag} Ω\n";
echo "归一化阻抗: Z/Z0 = " .
round(real($normalized['z_normalized']), 4) . " + j" .
round(imag($normalized['z_normalized']), 4) . "\n";
echo "反射系数: Γ = " .
round(real($normalized['gamma']), 4) . " + j" .
round(imag($normalized['gamma']), 4) . "\n";
echo "反射系数幅度: |Γ| = " . round($normalized['gamma_magnitude'], 4) . "\n";
// 在控制理论中的应用
echo "\n控制系统中的双曲函数:\n";
class ControlSystem {
// 计算Lyapunov指数(使用双曲函数)
public static function lyapunovExponent($lambda) {
// 简化版的Lyapunov指数计算
// 实际计算更复杂,这里仅作演示
if ($lambda <= 0) {
throw new InvalidArgumentException("λ 必须大于0");
}
// 使用atanh进行变换
$transformed = atanh(1 - 2 / ($lambda + 1));
return [
'lambda' => $lambda,
'transformed' => $transformed,
'stability' => $lambda < 1 ? '稳定' : ($lambda > 1 ? '不稳定' : '临界稳定')
];
}
// 计算系统的阻尼比
public static function dampingRatio($overshoot_percent) {
// 从超调量计算阻尼比
if ($overshoot_percent <= 0 || $overshoot_percent >= 100) {
throw new InvalidArgumentException("超调量必须在 0 到 100 之间");
}
$overshoot = $overshoot_percent / 100;
// 使用公式: ζ = sqrt(ln(overshoot)² / (π² + ln(overshoot)²))
// 或使用双曲函数
$ln_overshoot = log($overshoot);
$zeta = abs($ln_overshoot) / sqrt(M_PI * M_PI + $ln_overshoot * $ln_overshoot);
// 使用atanh的替代计算
$zeta_atanh = tanh(atanh(sqrt(1 - $zeta * $zeta)));
return [
'overshoot' => $overshoot_percent . '%',
'damping_ratio' => $zeta,
'damping_ratio_atanh' => $zeta_atanh,
'type' => $zeta < 0.7 ? '欠阻尼' : ($zeta > 1 ? '过阻尼' : '临界阻尼')
];
}
}
// Lyapunov指数计算
echo "Lyapunov指数分析:\n";
$lambda_values = [0.5, 0.8, 1.0, 1.2, 2.0];
foreach ($lambda_values as $lambda) {
try {
$result = ControlSystem::lyapunovExponent($lambda);
echo "λ = $lambda: 变换值 = " . round($result['transformed'], 4) .
", 稳定性: " . $result['stability'] . "\n";
} catch (Exception $e) {
echo "λ = $lambda: " . $e->getMessage() . "\n";
}
}
echo "\n阻尼比计算:\n";
$overshoots = [5, 10, 20, 50]; // 百分比
foreach ($overshoots as $os) {
try {
$damping = ControlSystem::dampingRatio($os);
echo "超调量: " . $damping['overshoot'] .
" → 阻尼比 = " . round($damping['damping_ratio'], 4) .
" (" . $damping['type'] . ")\n";
} catch (Exception $e) {
echo "超调量 $os%: " . $e->getMessage() . "\n";
}
}
// 在热力学中的应用(相对论速度分布)
echo "\n相对论速度分布(统计物理):\n";
function relativisticVelocityDistribution($v, $c = 1, $T = 1, $m = 1) {
// 简化的相对论Maxwell-Boltzmann分布
// v: 速度 (0 < v < c)
// c: 光速
// T: 温度
// m: 粒子质量
if ($v <= 0 || $v >= $c) {
throw new InvalidArgumentException("速度必须在 0 和 c 之间");
}
$beta = $v / $c;
$gamma = 1 / sqrt(1 - $beta * $beta);
// 使用双曲函数
$rapidity = atanh($beta);
// 分布函数(简化)
$distribution = exp(-$m * $c * $c * ($gamma - 1) / $T);
return [
'velocity' => $v,
'beta' => $beta,
'gamma' => $gamma,
'rapidity' => $rapidity,
'distribution' => $distribution
];
}
$velocities = [0.1, 0.3, 0.5, 0.7, 0.9];
foreach ($velocities as $v) {
try {
$result = relativisticVelocityDistribution($v);
echo "速度 v = {$v}c: β = " . round($result['beta'], 4) .
", γ = " . round($result['gamma'], 4) .
", 快度 = " . round($result['rapidity'], 4) .
", 分布值 = " . sprintf("%.4e", $result['distribution']) . "\n";
} catch (Exception $e) {
echo "速度 $v: " . $e->getMessage() . "\n";
}
}
?>
对于任意实数 x ∈ (-1, 1),反双曲正切函数 y = atanh(x) 定义为:
y ∈ (-∞, ∞) 使得 tanh(y) = x
其中双曲正切函数定义为:tanh(y) = (eʸ - e⁻ʸ)/(eʸ + e⁻ʸ)
定义域: (-1, 1)
值域: (-∞, ∞)
| 场景 | 描述 | 公式/代码 |
|---|---|---|
| 统计学 | Fisher Z变换(相关系数正态化) | atanh($r) |
| 概率论 | 逻辑回归的链接函数变体 | atanh(2*$p-1) |
| 微波工程 | 传输线反射系数计算 | 相关复数计算 |
| 控制理论 | Lyapunov指数和阻尼比计算 | atanh(1-2/(λ+1)) |
| 相对论物理 | 速度的快度表示 | atanh($v/$c) |
NANatanh(NAN) 返回 NAN,atanh(±INF) 返回 NANtanh()计算双曲正切值
asinh()计算反双曲正弦值
acosh()计算反双曲余弦值
atanh()计算反双曲正切值(当前函数)
log()计算自然对数
exp()计算指数函数