
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 5e+136)
(+ x (* (- t_1 (tanh (/ x y))) (* y z)))
(fma (- (* y t_1) x) z x))))y = abs(y);
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 5e+136) {
tmp = x + ((t_1 - tanh((x / y))) * (y * z));
} else {
tmp = fma(((y * t_1) - x), z, x);
}
return tmp;
}
y = abs(y) function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 5e+136) tmp = Float64(x + Float64(Float64(t_1 - tanh(Float64(x / y))) * Float64(y * z))); else tmp = fma(Float64(Float64(y * t_1) - x), z, x); end return tmp end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 5e+136], N[(x + N[(N[(t$95$1 - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision] * z + x), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 5 \cdot 10^{+136}:\\
\;\;\;\;x + \left(t_1 - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot t_1 - x, z, x\right)\\
\end{array}
\end{array}
if y < 5.0000000000000002e136Initial program 97.7%
if 5.0000000000000002e136 < y Initial program 88.6%
+-commutative88.6%
*-commutative88.6%
associate-*r*95.4%
fma-def95.5%
Applied egg-rr95.5%
Taylor expanded in x around 0 64.7%
+-commutative64.7%
mul-1-neg64.7%
unsub-neg64.7%
Simplified96.9%
Final simplification97.6%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (fma (* y (- (tanh (/ t y)) (tanh (/ x y)))) z x))
y = abs(y);
double code(double x, double y, double z, double t) {
return fma((y * (tanh((t / y)) - tanh((x / y)))), z, x);
}
y = abs(y) function code(x, y, z, t) return fma(Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), z, x) end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, x\right)
\end{array}
Initial program 96.2%
+-commutative96.2%
*-commutative96.2%
associate-*r*98.8%
fma-def98.8%
Applied egg-rr98.8%
Final simplification98.8%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 2.6e+61) (+ x (* t_1 (* y z))) (fma (- (* y t_1) x) z x))))
y = abs(y);
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 2.6e+61) {
tmp = x + (t_1 * (y * z));
} else {
tmp = fma(((y * t_1) - x), z, x);
}
return tmp;
}
y = abs(y) function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 2.6e+61) tmp = Float64(x + Float64(t_1 * Float64(y * z))); else tmp = fma(Float64(Float64(y * t_1) - x), z, x); end return tmp end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 2.6e+61], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision] * z + x), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 2.6 \cdot 10^{+61}:\\
\;\;\;\;x + t_1 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot t_1 - x, z, x\right)\\
\end{array}
\end{array}
if y < 2.59999999999999973e61Initial program 97.6%
Taylor expanded in x around 0 22.0%
*-commutative22.0%
associate-/r*22.0%
div-sub22.0%
rec-exp22.0%
rec-exp22.0%
tanh-def-a79.7%
Simplified79.7%
if 2.59999999999999973e61 < y Initial program 90.8%
+-commutative90.8%
*-commutative90.8%
associate-*r*96.3%
fma-def96.3%
Applied egg-rr96.3%
Taylor expanded in x around 0 58.3%
+-commutative58.3%
mul-1-neg58.3%
unsub-neg58.3%
Simplified95.9%
Final simplification83.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 5e+172) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5e+172) {
tmp = x + (tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 5d+172) then
tmp = x + (tanh((t / y)) * (y * z))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5e+172) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 5e+172: tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 5e+172) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 5e+172) tmp = x + (tanh((t / y)) * (y * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 5e+172], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{+172}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 5.0000000000000001e172Initial program 97.8%
Taylor expanded in x around 0 23.3%
*-commutative23.3%
associate-/r*23.3%
div-sub23.3%
rec-exp23.3%
rec-exp23.3%
tanh-def-a80.6%
Simplified80.6%
if 5.0000000000000001e172 < y Initial program 85.5%
Taylor expanded in y around inf 88.3%
Final simplification81.6%
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(if (<= y 1.12e+35)
x
(if (or (<= y 7.6e+133) (not (<= y 1.35e+281)))
(+ x (* t z))
(* x (- 1.0 z)))))y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.12e+35) {
tmp = x;
} else if ((y <= 7.6e+133) || !(y <= 1.35e+281)) {
tmp = x + (t * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 1.12d+35) then
tmp = x
else if ((y <= 7.6d+133) .or. (.not. (y <= 1.35d+281))) then
tmp = x + (t * z)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.12e+35) {
tmp = x;
} else if ((y <= 7.6e+133) || !(y <= 1.35e+281)) {
tmp = x + (t * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1.12e+35: tmp = x elif (y <= 7.6e+133) or not (y <= 1.35e+281): tmp = x + (t * z) else: tmp = x * (1.0 - z) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.12e+35) tmp = x; elseif ((y <= 7.6e+133) || !(y <= 1.35e+281)) tmp = Float64(x + Float64(t * z)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.12e+35) tmp = x; elseif ((y <= 7.6e+133) || ~((y <= 1.35e+281))) tmp = x + (t * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 1.12e+35], x, If[Or[LessEqual[y, 7.6e+133], N[Not[LessEqual[y, 1.35e+281]], $MachinePrecision]], N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.12 \cdot 10^{+35}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{+133} \lor \neg \left(y \leq 1.35 \cdot 10^{+281}\right):\\
\;\;\;\;x + t \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 1.12000000000000003e35Initial program 97.5%
Taylor expanded in x around inf 60.6%
if 1.12000000000000003e35 < y < 7.6000000000000004e133 or 1.35000000000000004e281 < y Initial program 95.5%
Taylor expanded in x around 0 33.9%
*-commutative33.9%
associate-/r*34.0%
div-sub34.0%
rec-exp34.2%
rec-exp34.2%
tanh-def-a91.0%
Simplified86.3%
Taylor expanded in y around inf 76.0%
if 7.6000000000000004e133 < y < 1.35000000000000004e281Initial program 89.6%
Taylor expanded in y around inf 84.8%
Taylor expanded in x around inf 69.3%
*-commutative69.3%
+-commutative69.3%
distribute-lft-in69.3%
metadata-eval69.3%
distribute-rgt-neg-in69.3%
*-commutative69.3%
mul-1-neg69.3%
remove-double-neg69.3%
mul-1-neg69.3%
distribute-rgt-neg-in69.3%
*-commutative69.3%
unsub-neg69.3%
*-commutative69.3%
Simplified69.3%
Taylor expanded in x around 0 69.3%
Final simplification63.1%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 8.5e-40) x (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.5e-40) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 8.5d-40) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.5e-40) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 8.5e-40: tmp = x else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 8.5e-40) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 8.5e-40) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 8.5e-40], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{-40}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 8.4999999999999998e-40Initial program 97.4%
Taylor expanded in x around inf 60.9%
if 8.4999999999999998e-40 < y Initial program 93.1%
Taylor expanded in y around inf 77.4%
Final simplification65.4%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= x -7.2e-121) x (if (<= x 1.05e-179) (* t z) x)))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.2e-121) {
tmp = x;
} else if (x <= 1.05e-179) {
tmp = t * z;
} else {
tmp = x;
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (x <= (-7.2d-121)) then
tmp = x
else if (x <= 1.05d-179) then
tmp = t * z
else
tmp = x
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.2e-121) {
tmp = x;
} else if (x <= 1.05e-179) {
tmp = t * z;
} else {
tmp = x;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if x <= -7.2e-121: tmp = x elif x <= 1.05e-179: tmp = t * z else: tmp = x return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (x <= -7.2e-121) tmp = x; elseif (x <= 1.05e-179) tmp = Float64(t * z); else tmp = x; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -7.2e-121) tmp = x; elseif (x <= 1.05e-179) tmp = t * z; else tmp = x; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[x, -7.2e-121], x, If[LessEqual[x, 1.05e-179], N[(t * z), $MachinePrecision], x]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{-121}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-179}:\\
\;\;\;\;t \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -7.19999999999999967e-121 or 1.0499999999999999e-179 < x Initial program 96.0%
Taylor expanded in x around inf 71.2%
if -7.19999999999999967e-121 < x < 1.0499999999999999e-179Initial program 96.8%
Taylor expanded in y around inf 54.1%
Taylor expanded in x around 0 37.8%
Final simplification63.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 8.2e+60) x (* x (- 1.0 z))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.2e+60) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 8.2d+60) then
tmp = x
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.2e+60) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 8.2e+60: tmp = x else: tmp = x * (1.0 - z) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 8.2e+60) tmp = x; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 8.2e+60) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 8.2e+60], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.2 \cdot 10^{+60}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 8.2e60Initial program 97.6%
Taylor expanded in x around inf 60.3%
if 8.2e60 < y Initial program 90.8%
Taylor expanded in y around inf 87.5%
Taylor expanded in x around inf 69.0%
*-commutative69.0%
+-commutative69.0%
distribute-lft-in69.0%
metadata-eval69.0%
distribute-rgt-neg-in69.0%
*-commutative69.0%
mul-1-neg69.0%
remove-double-neg69.0%
mul-1-neg69.0%
distribute-rgt-neg-in69.0%
*-commutative69.0%
unsub-neg69.0%
*-commutative69.0%
Simplified69.0%
Taylor expanded in x around 0 69.0%
Final simplification62.1%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 x)
y = abs(y);
double code(double x, double y, double z, double t) {
return x;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
return x;
}
y = abs(y) def code(x, y, z, t): return x
y = abs(y) function code(x, y, z, t) return x end
y = abs(y) function tmp = code(x, y, z, t) tmp = x; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := x
\begin{array}{l}
y = |y|\\
\\
x
\end{array}
Initial program 96.2%
Taylor expanded in x around inf 59.4%
Final simplification59.4%
(FPCore (x y z t) :precision binary64 (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}
herbie shell --seed 2023274
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:herbie-target
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))