
(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 11 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 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := 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}
\\
\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 91.8%
+-commutative91.8%
*-commutative91.8%
associate-*l*97.4%
fma-def97.4%
Simplified97.4%
Final simplification97.4%
(FPCore (x y z t) :precision binary64 (+ x (* y (- (* z (tanh (/ t y))) (* z (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * ((z * tanh((t / y))) - (z * 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))) - (z * 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))) - (z * Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * ((z * math.tanh((t / y))) - (z * math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(Float64(z * tanh(Float64(t / y))) - Float64(z * tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * ((z * tanh((t / y))) - (z * tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right) - z \cdot \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Initial program 91.8%
associate-*l*97.0%
Simplified97.0%
sub-neg97.0%
distribute-rgt-in97.0%
Applied egg-rr97.0%
Final simplification97.0%
(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}
Initial program 91.8%
associate-*l*97.0%
Simplified97.0%
Final simplification97.0%
(FPCore (x y z t) :precision binary64 (if (or (<= t -0.00055) (not (<= t 8.2e-47))) (fma z (* y (tanh (/ t y))) x) (+ x (* z (- t (* y (tanh (/ x y))))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -0.00055) || !(t <= 8.2e-47)) {
tmp = fma(z, (y * tanh((t / y))), x);
} else {
tmp = x + (z * (t - (y * tanh((x / y)))));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((t <= -0.00055) || !(t <= 8.2e-47)) tmp = fma(z, Float64(y * tanh(Float64(t / y))), x); else tmp = Float64(x + Float64(z * Float64(t - Float64(y * tanh(Float64(x / y)))))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -0.00055], N[Not[LessEqual[t, 8.2e-47]], $MachinePrecision]], N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(z * N[(t - N[(y * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.00055 \lor \neg \left(t \leq 8.2 \cdot 10^{-47}\right):\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot \tanh \left(\frac{t}{y}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - y \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -5.50000000000000033e-4 or 8.20000000000000003e-47 < t Initial program 95.3%
+-commutative95.3%
*-commutative95.3%
associate-*l*99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in x around 0 9.2%
associate-/r*9.2%
div-sub9.2%
rec-exp9.2%
rec-exp9.2%
tanh-def-a87.2%
Simplified87.2%
if -5.50000000000000033e-4 < t < 8.20000000000000003e-47Initial program 87.6%
Taylor expanded in t around 0 84.3%
Taylor expanded in t around -inf 40.7%
+-commutative40.7%
mul-1-neg40.7%
unsub-neg40.7%
Simplified93.5%
Taylor expanded in z around 0 40.7%
*-commutative40.7%
associate-/r*40.7%
div-sub40.7%
rec-exp40.7%
rec-exp40.7%
Simplified93.5%
Final simplification90.0%
(FPCore (x y z t) :precision binary64 (if (or (<= t -0.0007) (not (<= t 0.00034))) (+ x (* (tanh (/ t y)) (* z y))) (+ x (* z (- t (* y (tanh (/ x y))))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -0.0007) || !(t <= 0.00034)) {
tmp = x + (tanh((t / y)) * (z * y));
} else {
tmp = x + (z * (t - (y * tanh((x / y)))));
}
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 ((t <= (-0.0007d0)) .or. (.not. (t <= 0.00034d0))) then
tmp = x + (tanh((t / y)) * (z * y))
else
tmp = x + (z * (t - (y * tanh((x / y)))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -0.0007) || !(t <= 0.00034)) {
tmp = x + (Math.tanh((t / y)) * (z * y));
} else {
tmp = x + (z * (t - (y * Math.tanh((x / y)))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -0.0007) or not (t <= 0.00034): tmp = x + (math.tanh((t / y)) * (z * y)) else: tmp = x + (z * (t - (y * math.tanh((x / y))))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -0.0007) || !(t <= 0.00034)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))); else tmp = Float64(x + Float64(z * Float64(t - Float64(y * tanh(Float64(x / y)))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -0.0007) || ~((t <= 0.00034))) tmp = x + (tanh((t / y)) * (z * y)); else tmp = x + (z * (t - (y * tanh((x / y))))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -0.0007], N[Not[LessEqual[t, 0.00034]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - N[(y * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.0007 \lor \neg \left(t \leq 0.00034\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - y \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -6.99999999999999993e-4 or 3.4e-4 < t Initial program 96.5%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around 0 8.2%
*-commutative8.2%
associate-/r*8.2%
div-sub8.2%
rec-exp8.2%
rec-exp8.2%
Simplified84.5%
if -6.99999999999999993e-4 < t < 3.4e-4Initial program 86.7%
Taylor expanded in t around 0 83.7%
Taylor expanded in t around -inf 40.8%
+-commutative40.8%
mul-1-neg40.8%
unsub-neg40.8%
Simplified93.1%
Taylor expanded in z around 0 40.8%
*-commutative40.8%
associate-/r*40.8%
div-sub40.8%
rec-exp40.8%
rec-exp40.8%
Simplified93.2%
Final simplification88.7%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.85e+122) (not (<= y 3.5e+85))) (+ x (* z (- t x))) (+ x (* (tanh (/ t y)) (* z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.85e+122) || !(y <= 3.5e+85)) {
tmp = x + (z * (t - x));
} else {
tmp = x + (tanh((t / y)) * (z * y));
}
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.85d+122)) .or. (.not. (y <= 3.5d+85))) then
tmp = x + (z * (t - x))
else
tmp = x + (tanh((t / y)) * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.85e+122) || !(y <= 3.5e+85)) {
tmp = x + (z * (t - x));
} else {
tmp = x + (Math.tanh((t / y)) * (z * y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.85e+122) or not (y <= 3.5e+85): tmp = x + (z * (t - x)) else: tmp = x + (math.tanh((t / y)) * (z * y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.85e+122) || !(y <= 3.5e+85)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -2.85e+122) || ~((y <= 3.5e+85))) tmp = x + (z * (t - x)); else tmp = x + (tanh((t / y)) * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.85e+122], N[Not[LessEqual[y, 3.5e+85]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.85 \cdot 10^{+122} \lor \neg \left(y \leq 3.5 \cdot 10^{+85}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if y < -2.85000000000000003e122 or 3.50000000000000005e85 < y Initial program 81.2%
associate-*l*92.8%
Simplified92.8%
Taylor expanded in y around inf 87.6%
if -2.85000000000000003e122 < y < 3.50000000000000005e85Initial program 99.3%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around 0 23.6%
*-commutative23.6%
associate-/r*23.6%
div-sub23.6%
rec-exp23.6%
rec-exp23.6%
Simplified82.7%
Final simplification84.7%
(FPCore (x y z t) :precision binary64 (if (or (<= y -8.8e+36) (not (<= y 7.5e-78))) (+ x (* z (- t x))) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -8.8e+36) || !(y <= 7.5e-78)) {
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 <= (-8.8d+36)) .or. (.not. (y <= 7.5d-78))) 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 <= -8.8e+36) || !(y <= 7.5e-78)) {
tmp = x + (z * (t - x));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -8.8e+36) or not (y <= 7.5e-78): tmp = x + (z * (t - x)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -8.8e+36) || !(y <= 7.5e-78)) 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 <= -8.8e+36) || ~((y <= 7.5e-78))) tmp = x + (z * (t - x)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -8.8e+36], N[Not[LessEqual[y, 7.5e-78]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.8 \cdot 10^{+36} \lor \neg \left(y \leq 7.5 \cdot 10^{-78}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -8.80000000000000002e36 or 7.50000000000000041e-78 < y Initial program 85.9%
associate-*l*94.8%
Simplified94.8%
Taylor expanded in y around inf 78.3%
if -8.80000000000000002e36 < y < 7.50000000000000041e-78Initial program 100.0%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in y around inf 38.8%
Taylor expanded in z around 0 80.5%
Final simplification79.2%
(FPCore (x y z t) :precision binary64 (if (or (<= y -8.6e+53) (not (<= y 3.6e-78))) (+ x (* z t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -8.6e+53) || !(y <= 3.6e-78)) {
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 <= (-8.6d+53)) .or. (.not. (y <= 3.6d-78))) 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 <= -8.6e+53) || !(y <= 3.6e-78)) {
tmp = x + (z * t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -8.6e+53) or not (y <= 3.6e-78): tmp = x + (z * t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -8.6e+53) || !(y <= 3.6e-78)) 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 <= -8.6e+53) || ~((y <= 3.6e-78))) tmp = x + (z * t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -8.6e+53], N[Not[LessEqual[y, 3.6e-78]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.6 \cdot 10^{+53} \lor \neg \left(y \leq 3.6 \cdot 10^{-78}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -8.5999999999999995e53 or 3.6000000000000002e-78 < y Initial program 85.5%
associate-*l*94.7%
Simplified94.7%
Taylor expanded in x around 0 27.7%
*-commutative27.7%
associate-/r*27.7%
div-sub27.7%
rec-exp27.7%
rec-exp27.7%
Simplified73.0%
Taylor expanded in y around inf 67.2%
if -8.5999999999999995e53 < y < 3.6000000000000002e-78Initial program 100.0%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in y around inf 39.3%
Taylor expanded in z around 0 79.4%
Final simplification72.5%
(FPCore (x y z t) :precision binary64 (if (<= y -8.5e+81) (* x (- 1.0 z)) (if (<= y 2.4e+67) x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -8.5e+81) {
tmp = x * (1.0 - z);
} else if (y <= 2.4e+67) {
tmp = x;
} else {
tmp = z * t;
}
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 <= (-8.5d+81)) then
tmp = x * (1.0d0 - z)
else if (y <= 2.4d+67) then
tmp = x
else
tmp = z * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -8.5e+81) {
tmp = x * (1.0 - z);
} else if (y <= 2.4e+67) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -8.5e+81: tmp = x * (1.0 - z) elif y <= 2.4e+67: tmp = x else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -8.5e+81) tmp = Float64(x * Float64(1.0 - z)); elseif (y <= 2.4e+67) tmp = x; else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -8.5e+81) tmp = x * (1.0 - z); elseif (y <= 2.4e+67) tmp = x; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -8.5e+81], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.4e+67], x, N[(z * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{+81}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+67}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < -8.49999999999999986e81Initial program 80.5%
associate-*l*94.1%
Simplified94.1%
Taylor expanded in y around inf 86.6%
Taylor expanded in x around inf 54.4%
*-commutative54.4%
+-commutative54.4%
mul-1-neg54.4%
unsub-neg54.4%
Simplified54.4%
if -8.49999999999999986e81 < y < 2.40000000000000002e67Initial program 99.9%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in y around inf 42.6%
Taylor expanded in z around 0 73.0%
if 2.40000000000000002e67 < y Initial program 82.8%
associate-*l*92.8%
Simplified92.8%
Taylor expanded in x around 0 26.4%
*-commutative26.4%
associate-/r*26.4%
div-sub26.4%
rec-exp26.4%
rec-exp26.4%
Simplified72.0%
Taylor expanded in y around inf 69.8%
Taylor expanded in t around inf 46.4%
Final simplification62.5%
(FPCore (x y z t) :precision binary64 (if (<= z -1.9e+147) (* z t) x))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.9e+147) {
tmp = 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 (z <= (-1.9d+147)) then
tmp = 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 (z <= -1.9e+147) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.9e+147: tmp = z * t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.9e+147) tmp = Float64(z * t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.9e+147) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.9e+147], N[(z * t), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+147}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.89999999999999985e147Initial program 85.6%
associate-*l*96.9%
Simplified96.9%
Taylor expanded in x around 0 8.1%
*-commutative8.1%
associate-/r*8.1%
div-sub8.1%
rec-exp8.1%
rec-exp8.1%
Simplified63.8%
Taylor expanded in y around inf 59.0%
Taylor expanded in t around inf 53.3%
if -1.89999999999999985e147 < z Initial program 92.7%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in y around inf 61.7%
Taylor expanded in z around 0 60.4%
Final simplification59.5%
(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 91.8%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in y around inf 61.8%
Taylor expanded in z around 0 54.2%
Final simplification54.2%
(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 2023176
(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))))))