
(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 10 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}
(FPCore (x y z t) :precision binary64 (if (<= y -3.25e+196) (fma z (- t x) x) (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.25e+196) {
tmp = fma(z, (t - x), x);
} else {
tmp = fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -3.25e+196) tmp = fma(z, Float64(t - x), x); else tmp = fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.25e+196], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.25 \cdot 10^{+196}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\\
\end{array}
\end{array}
if y < -3.24999999999999984e196Initial program 60.4%
associate-*l*76.2%
Simplified76.2%
Taylor expanded in y around inf 99.9%
+-commutative99.9%
fma-def100.0%
Simplified100.0%
if -3.24999999999999984e196 < y Initial program 96.2%
+-commutative96.2%
*-commutative96.2%
associate-*l*98.8%
fma-def98.8%
Simplified98.8%
Final simplification99.0%
(FPCore (x y z t) :precision binary64 (if (<= y -1.56e+177) (fma z (- t x) x) (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.56e+177) {
tmp = fma(z, (t - x), x);
} else {
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.56e+177) tmp = fma(z, Float64(t - x), x); else tmp = Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.56e+177], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.56 \cdot 10^{+177}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\end{array}
\end{array}
if y < -1.5600000000000001e177Initial program 64.2%
associate-*l*78.4%
Simplified78.4%
Taylor expanded in y around inf 99.9%
+-commutative99.9%
fma-def100.0%
Simplified100.0%
if -1.5600000000000001e177 < y Initial program 96.2%
associate-*l*98.3%
Simplified98.3%
Final simplification98.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y -3.4e+62)
(fma z (- t x) x)
(if (<= y 1.35e+72) (+ x (* t_1 (* y z))) (+ x (* z (- (* y t_1) x)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= -3.4e+62) {
tmp = fma(z, (t - x), x);
} else if (y <= 1.35e+72) {
tmp = x + (t_1 * (y * z));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= -3.4e+62) tmp = fma(z, Float64(t - x), x); elseif (y <= 1.35e+72) tmp = Float64(x + Float64(t_1 * Float64(y * z))); else tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -3.4e+62], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 1.35e+72], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq -3.4 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+72}:\\
\;\;\;\;x + t_1 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < -3.40000000000000014e62Initial program 77.4%
associate-*l*87.4%
Simplified87.4%
Taylor expanded in y around inf 89.7%
+-commutative89.7%
fma-def89.8%
Simplified89.8%
if -3.40000000000000014e62 < y < 1.35e72Initial program 99.3%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in x around 0 15.7%
*-commutative15.7%
associate-*r*15.7%
associate-/r*15.7%
div-sub15.7%
rec-exp15.7%
rec-exp15.7%
Simplified85.4%
if 1.35e72 < y Initial program 85.7%
associate-*l*92.0%
Simplified92.0%
Taylor expanded in x around 0 92.0%
Taylor expanded in y around 0 57.1%
+-commutative57.1%
mul-1-neg57.1%
distribute-rgt-neg-out57.1%
*-commutative57.1%
associate-*r*57.1%
distribute-rgt-out57.1%
Simplified94.2%
Taylor expanded in z around 0 57.1%
associate-*r/57.1%
rec-exp57.1%
rec-exp57.1%
tanh-def-a94.2%
Simplified94.2%
Final simplification87.9%
(FPCore (x y z t) :precision binary64 (if (<= y -9.2e+60) (fma z (- t x) x) (if (<= y 3e+109) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* z (- t x))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9.2e+60) {
tmp = fma(z, (t - x), x);
} else if (y <= 3e+109) {
tmp = x + (tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -9.2e+60) tmp = fma(z, Float64(t - x), x); elseif (y <= 3e+109) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -9.2e+60], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 3e+109], 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}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+109}:\\
\;\;\;\;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 < -9.20000000000000068e60Initial program 77.4%
associate-*l*87.4%
Simplified87.4%
Taylor expanded in y around inf 89.7%
+-commutative89.7%
fma-def89.8%
Simplified89.8%
if -9.20000000000000068e60 < y < 3.00000000000000015e109Initial program 98.7%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in x around 0 16.3%
*-commutative16.3%
associate-*r*16.3%
associate-/r*16.3%
div-sub16.3%
rec-exp16.3%
rec-exp16.3%
Simplified84.9%
if 3.00000000000000015e109 < y Initial program 85.6%
+-commutative85.6%
*-commutative85.6%
associate-*l*93.1%
fma-def93.1%
Simplified93.1%
Taylor expanded in y around inf 92.7%
Final simplification87.1%
(FPCore (x y z t) :precision binary64 (if (<= y -7.5e-71) (fma z (- t x) x) (if (<= y 1.35e+72) x (+ x (* z (- t x))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -7.5e-71) {
tmp = fma(z, (t - x), x);
} else if (y <= 1.35e+72) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -7.5e-71) tmp = fma(z, Float64(t - x), x); elseif (y <= 1.35e+72) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -7.5e-71], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 1.35e+72], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{-71}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+72}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < -7.5000000000000004e-71Initial program 85.1%
associate-*l*91.7%
Simplified91.7%
Taylor expanded in y around inf 81.1%
+-commutative81.1%
fma-def81.1%
Simplified81.1%
if -7.5000000000000004e-71 < y < 1.35e72Initial program 99.2%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around inf 78.1%
if 1.35e72 < y Initial program 85.7%
+-commutative85.7%
*-commutative85.7%
associate-*l*94.2%
fma-def94.2%
Simplified94.2%
Taylor expanded in y around inf 87.8%
Final simplification80.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2e-70) (not (<= y 3.4e+73))) (+ x (* z (- t x))) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2e-70) || !(y <= 3.4e+73)) {
tmp = x + (z * (t - x));
} else {
tmp = x;
}
return tmp;
}
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 <= (-2d-70)) .or. (.not. (y <= 3.4d+73))) then
tmp = x + (z * (t - x))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2e-70) || !(y <= 3.4e+73)) {
tmp = x + (z * (t - x));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2e-70) or not (y <= 3.4e+73): tmp = x + (z * (t - x)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2e-70) || !(y <= 3.4e+73)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -2e-70) || ~((y <= 3.4e+73))) tmp = x + (z * (t - x)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2e-70], N[Not[LessEqual[y, 3.4e+73]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-70} \lor \neg \left(y \leq 3.4 \cdot 10^{+73}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.99999999999999999e-70 or 3.4000000000000002e73 < y Initial program 85.3%
+-commutative85.3%
*-commutative85.3%
associate-*l*93.6%
fma-def93.6%
Simplified93.6%
Taylor expanded in y around inf 83.4%
if -1.99999999999999999e-70 < y < 3.4000000000000002e73Initial program 99.2%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around inf 78.1%
Final simplification80.7%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.95e+27) (not (<= y 2.5e+75))) (* x (- 1.0 z)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.95e+27) || !(y <= 2.5e+75)) {
tmp = x * (1.0 - z);
} else {
tmp = x;
}
return tmp;
}
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.95d+27)) .or. (.not. (y <= 2.5d+75))) then
tmp = x * (1.0d0 - z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.95e+27) || !(y <= 2.5e+75)) {
tmp = x * (1.0 - z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.95e+27) or not (y <= 2.5e+75): tmp = x * (1.0 - z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.95e+27) || !(y <= 2.5e+75)) tmp = Float64(x * Float64(1.0 - z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.95e+27) || ~((y <= 2.5e+75))) tmp = x * (1.0 - z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.95e+27], N[Not[LessEqual[y, 2.5e+75]], $MachinePrecision]], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{+27} \lor \neg \left(y \leq 2.5 \cdot 10^{+75}\right):\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.9499999999999999e27 or 2.5000000000000001e75 < y Initial program 82.9%
+-commutative82.9%
*-commutative82.9%
associate-*l*92.1%
fma-def92.1%
Simplified92.1%
Taylor expanded in y around inf 87.9%
Taylor expanded in t around 0 57.3%
associate-*r*57.3%
*-lft-identity57.3%
distribute-rgt-in57.3%
+-commutative57.3%
mul-1-neg57.3%
unsub-neg57.3%
Simplified57.3%
if -1.9499999999999999e27 < y < 2.5000000000000001e75Initial program 98.7%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around inf 74.4%
Final simplification67.5%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.5e-70) (not (<= y 2e+72))) (+ x (* z t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.5e-70) || !(y <= 2e+72)) {
tmp = x + (z * t);
} else {
tmp = x;
}
return tmp;
}
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 <= (-2.5d-70)) .or. (.not. (y <= 2d+72))) then
tmp = x + (z * t)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.5e-70) || !(y <= 2e+72)) {
tmp = x + (z * t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.5e-70) or not (y <= 2e+72): tmp = x + (z * t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.5e-70) || !(y <= 2e+72)) tmp = Float64(x + Float64(z * t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -2.5e-70) || ~((y <= 2e+72))) tmp = x + (z * t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.5e-70], N[Not[LessEqual[y, 2e+72]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{-70} \lor \neg \left(y \leq 2 \cdot 10^{+72}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -2.4999999999999999e-70 or 1.99999999999999989e72 < y Initial program 85.3%
associate-*l*91.8%
Simplified91.8%
Taylor expanded in x around 0 41.1%
*-commutative41.1%
associate-*r*40.5%
associate-/r*40.5%
div-sub40.5%
rec-exp40.5%
rec-exp40.5%
Simplified73.6%
Taylor expanded in y around inf 72.0%
if -2.4999999999999999e-70 < y < 1.99999999999999989e72Initial program 99.2%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around inf 78.1%
Final simplification75.1%
(FPCore (x y z t) :precision binary64 (if (<= y -1.56e+62) (* z (- t x)) (if (<= y 5e+77) x (* x (- 1.0 z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.56e+62) {
tmp = z * (t - x);
} else if (y <= 5e+77) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
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.56d+62)) then
tmp = z * (t - x)
else if (y <= 5d+77) then
tmp = x
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.56e+62) {
tmp = z * (t - x);
} else if (y <= 5e+77) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.56e+62: tmp = z * (t - x) elif y <= 5e+77: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.56e+62) tmp = Float64(z * Float64(t - x)); elseif (y <= 5e+77) tmp = x; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.56e+62) tmp = z * (t - x); elseif (y <= 5e+77) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.56e+62], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e+77], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.56 \cdot 10^{+62}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+77}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -1.55999999999999995e62Initial program 77.4%
+-commutative77.4%
*-commutative77.4%
associate-*l*89.7%
fma-def89.7%
Simplified89.7%
Taylor expanded in y around inf 89.7%
Taylor expanded in z around inf 56.0%
if -1.55999999999999995e62 < y < 5.00000000000000004e77Initial program 98.7%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in x around inf 74.0%
if 5.00000000000000004e77 < y Initial program 87.6%
+-commutative87.6%
*-commutative87.6%
associate-*l*94.1%
fma-def94.1%
Simplified94.1%
Taylor expanded in y around inf 87.5%
Taylor expanded in t around 0 59.1%
associate-*r*59.1%
*-lft-identity59.1%
distribute-rgt-in59.1%
+-commutative59.1%
mul-1-neg59.1%
unsub-neg59.1%
Simplified59.1%
Final simplification67.6%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
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
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 92.3%
associate-*l*95.9%
Simplified95.9%
Taylor expanded in x around inf 61.4%
Final simplification61.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 2023195
(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))))))