
(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
(let* ((t_1 (- (tanh (/ t y)) (tanh (/ x y)))))
(if (<= (+ x (* (* y z) t_1)) 2e+300)
(+ x (* z (* y t_1)))
(+ (* x (- 1.0 z)) (* z t)))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y)) - tanh((x / y));
double tmp;
if ((x + ((y * z) * t_1)) <= 2e+300) {
tmp = x + (z * (y * t_1));
} else {
tmp = (x * (1.0 - z)) + (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) :: t_1
real(8) :: tmp
t_1 = tanh((t / y)) - tanh((x / y))
if ((x + ((y * z) * t_1)) <= 2d+300) then
tmp = x + (z * (y * t_1))
else
tmp = (x * (1.0d0 - z)) + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y)) - Math.tanh((x / y));
double tmp;
if ((x + ((y * z) * t_1)) <= 2e+300) {
tmp = x + (z * (y * t_1));
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) - math.tanh((x / y)) tmp = 0 if (x + ((y * z) * t_1)) <= 2e+300: tmp = x + (z * (y * t_1)) else: tmp = (x * (1.0 - z)) + (z * t) return tmp
function code(x, y, z, t) t_1 = Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) tmp = 0.0 if (Float64(x + Float64(Float64(y * z) * t_1)) <= 2e+300) tmp = Float64(x + Float64(z * Float64(y * t_1))); else tmp = Float64(Float64(x * Float64(1.0 - z)) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)) - tanh((x / y)); tmp = 0.0; if ((x + ((y * z) * t_1)) <= 2e+300) tmp = x + (z * (y * t_1)); else tmp = (x * (1.0 - z)) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x + N[(N[(y * z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2e+300], N[(x + N[(z * N[(y * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\
\mathbf{if}\;x + \left(y \cdot z\right) \cdot t_1 \leq 2 \cdot 10^{+300}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.0000000000000001e300Initial program 96.6%
associate-*l*98.4%
Simplified98.4%
associate-*r*96.6%
sub-neg96.6%
distribute-lft-in94.7%
Applied egg-rr94.7%
distribute-lft-out96.6%
*-commutative96.6%
sub-neg96.6%
associate-*r*99.2%
Simplified99.2%
if 2.0000000000000001e300 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 45.0%
associate-*l*75.8%
Simplified75.8%
Taylor expanded in y around inf 99.9%
Taylor expanded in x around 0 100.0%
Final simplification99.3%
(FPCore (x y z t) :precision binary64 (if (<= y 1.55e+137) (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))) (+ (* x (- 1.0 z)) (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.55e+137) {
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
} else {
tmp = (x * (1.0 - z)) + (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 <= 1.55d+137) then
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
else
tmp = (x * (1.0d0 - z)) + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.55e+137) {
tmp = x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.55e+137: tmp = x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y))))) else: tmp = (x * (1.0 - z)) + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.55e+137) tmp = Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))); else tmp = Float64(Float64(x * Float64(1.0 - z)) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.55e+137) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); else tmp = (x * (1.0 - z)) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.55e+137], 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], N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.55 \cdot 10^{+137}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\
\end{array}
\end{array}
if y < 1.55e137Initial program 95.9%
associate-*l*97.4%
Simplified97.4%
if 1.55e137 < y Initial program 65.0%
associate-*l*87.9%
Simplified87.9%
Taylor expanded in y around inf 99.8%
Taylor expanded in x around 0 99.9%
Final simplification97.8%
(FPCore (x y z t)
:precision binary64
(if (<= y -1.05e+191)
(+ x (* z (- t x)))
(if (<= y 2.8e+130)
(+ x (* y (* z (tanh (/ t y)))))
(+ (* x (- 1.0 z)) (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.05e+191) {
tmp = x + (z * (t - x));
} else if (y <= 2.8e+130) {
tmp = x + (y * (z * tanh((t / y))));
} else {
tmp = (x * (1.0 - z)) + (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 <= (-1.05d+191)) then
tmp = x + (z * (t - x))
else if (y <= 2.8d+130) then
tmp = x + (y * (z * tanh((t / y))))
else
tmp = (x * (1.0d0 - z)) + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.05e+191) {
tmp = x + (z * (t - x));
} else if (y <= 2.8e+130) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.05e+191: tmp = x + (z * (t - x)) elif y <= 2.8e+130: tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = (x * (1.0 - z)) + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.05e+191) tmp = Float64(x + Float64(z * Float64(t - x))); elseif (y <= 2.8e+130) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); else tmp = Float64(Float64(x * Float64(1.0 - z)) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.05e+191) tmp = x + (z * (t - x)); elseif (y <= 2.8e+130) tmp = x + (y * (z * tanh((t / y)))); else tmp = (x * (1.0 - z)) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.05e+191], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.8e+130], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+191}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+130}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\
\end{array}
\end{array}
if y < -1.05e191Initial program 71.3%
associate-*l*83.2%
Simplified83.2%
Taylor expanded in y around inf 93.7%
if -1.05e191 < y < 2.7999999999999999e130Initial program 99.4%
associate-*l*99.5%
Simplified99.5%
Taylor expanded in x around 0 29.9%
associate-/r*30.0%
div-sub29.9%
rec-exp29.9%
rec-exp29.9%
tanh-def-a85.7%
Simplified85.7%
if 2.7999999999999999e130 < y Initial program 66.6%
associate-*l*88.5%
Simplified88.5%
Taylor expanded in y around inf 97.8%
Taylor expanded in x around 0 97.8%
Final simplification88.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y -3.2e-64)
(+ x (* z (- (* y t_1) x)))
(if (<= y 1.55e+131) (+ x (* y (* z t_1))) (+ (* x (- 1.0 z)) (* z t))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= -3.2e-64) {
tmp = x + (z * ((y * t_1) - x));
} else if (y <= 1.55e+131) {
tmp = x + (y * (z * t_1));
} else {
tmp = (x * (1.0 - z)) + (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) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= (-3.2d-64)) then
tmp = x + (z * ((y * t_1) - x))
else if (y <= 1.55d+131) then
tmp = x + (y * (z * t_1))
else
tmp = (x * (1.0d0 - z)) + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= -3.2e-64) {
tmp = x + (z * ((y * t_1) - x));
} else if (y <= 1.55e+131) {
tmp = x + (y * (z * t_1));
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= -3.2e-64: tmp = x + (z * ((y * t_1) - x)) elif y <= 1.55e+131: tmp = x + (y * (z * t_1)) else: tmp = (x * (1.0 - z)) + (z * t) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= -3.2e-64) tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); elseif (y <= 1.55e+131) tmp = Float64(x + Float64(y * Float64(z * t_1))); else tmp = Float64(Float64(x * Float64(1.0 - z)) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= -3.2e-64) tmp = x + (z * ((y * t_1) - x)); elseif (y <= 1.55e+131) tmp = x + (y * (z * t_1)); else tmp = (x * (1.0 - z)) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -3.2e-64], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.55e+131], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq -3.2 \cdot 10^{-64}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+131}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\
\end{array}
\end{array}
if y < -3.19999999999999975e-64Initial program 90.3%
associate-*l*93.2%
Simplified93.2%
associate-*r*90.3%
sub-neg90.3%
distribute-lft-in87.6%
Applied egg-rr87.6%
distribute-lft-out90.3%
*-commutative90.3%
sub-neg90.3%
associate-*r*95.5%
Simplified95.5%
Taylor expanded in x around 0 53.3%
+-commutative53.3%
mul-1-neg53.3%
unsub-neg53.3%
Simplified91.3%
if -3.19999999999999975e-64 < y < 1.55000000000000008e131Initial program 99.2%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in x around 0 21.4%
associate-/r*21.4%
div-sub21.4%
rec-exp21.4%
rec-exp21.4%
tanh-def-a86.3%
Simplified86.3%
if 1.55000000000000008e131 < y Initial program 66.6%
associate-*l*88.5%
Simplified88.5%
Taylor expanded in y around inf 97.8%
Taylor expanded in x around 0 97.8%
Final simplification89.8%
(FPCore (x y z t) :precision binary64 (if (<= y -3.6e-68) (+ x (* z (- t x))) (if (<= y 4.7e+32) x (+ (* x (- 1.0 z)) (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.6e-68) {
tmp = x + (z * (t - x));
} else if (y <= 4.7e+32) {
tmp = x;
} else {
tmp = (x * (1.0 - z)) + (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 <= (-3.6d-68)) then
tmp = x + (z * (t - x))
else if (y <= 4.7d+32) then
tmp = x
else
tmp = (x * (1.0d0 - z)) + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.6e-68) {
tmp = x + (z * (t - x));
} else if (y <= 4.7e+32) {
tmp = x;
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.6e-68: tmp = x + (z * (t - x)) elif y <= 4.7e+32: tmp = x else: tmp = (x * (1.0 - z)) + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.6e-68) tmp = Float64(x + Float64(z * Float64(t - x))); elseif (y <= 4.7e+32) tmp = x; else tmp = Float64(Float64(x * Float64(1.0 - z)) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -3.6e-68) tmp = x + (z * (t - x)); elseif (y <= 4.7e+32) tmp = x; else tmp = (x * (1.0 - z)) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.6e-68], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.7e+32], x, N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{-68}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{elif}\;y \leq 4.7 \cdot 10^{+32}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\
\end{array}
\end{array}
if y < -3.60000000000000007e-68Initial program 90.4%
associate-*l*93.2%
Simplified93.2%
Taylor expanded in y around inf 80.1%
if -3.60000000000000007e-68 < y < 4.70000000000000023e32Initial program 100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in y around inf 38.5%
Taylor expanded in z around 0 73.9%
if 4.70000000000000023e32 < y Initial program 77.8%
associate-*l*92.8%
Simplified92.8%
Taylor expanded in y around inf 83.7%
Taylor expanded in x around 0 83.7%
Final simplification78.5%
(FPCore (x y z t) :precision binary64 (if (<= y -1.6e+248) (* z (- t x)) (if (or (<= y -7.8e-83) (not (<= y 2.55e-34))) (+ x (* z t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.6e+248) {
tmp = z * (t - x);
} else if ((y <= -7.8e-83) || !(y <= 2.55e-34)) {
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 <= (-1.6d+248)) then
tmp = z * (t - x)
else if ((y <= (-7.8d-83)) .or. (.not. (y <= 2.55d-34))) 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 <= -1.6e+248) {
tmp = z * (t - x);
} else if ((y <= -7.8e-83) || !(y <= 2.55e-34)) {
tmp = x + (z * t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.6e+248: tmp = z * (t - x) elif (y <= -7.8e-83) or not (y <= 2.55e-34): tmp = x + (z * t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.6e+248) tmp = Float64(z * Float64(t - x)); elseif ((y <= -7.8e-83) || !(y <= 2.55e-34)) 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 <= -1.6e+248) tmp = z * (t - x); elseif ((y <= -7.8e-83) || ~((y <= 2.55e-34))) tmp = x + (z * t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.6e+248], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -7.8e-83], N[Not[LessEqual[y, 2.55e-34]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.6 \cdot 10^{+248}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{elif}\;y \leq -7.8 \cdot 10^{-83} \lor \neg \left(y \leq 2.55 \cdot 10^{-34}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.59999999999999992e248Initial program 73.3%
associate-*l*82.5%
Simplified82.5%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 97.5%
if -1.59999999999999992e248 < y < -7.800000000000001e-83 or 2.55e-34 < y Initial program 86.9%
associate-*l*94.5%
Simplified94.5%
Taylor expanded in x around 0 39.8%
associate-/r*39.8%
div-sub39.8%
rec-exp39.8%
rec-exp39.8%
tanh-def-a79.1%
Simplified79.1%
Taylor expanded in y around inf 68.1%
if -7.800000000000001e-83 < y < 2.55e-34Initial program 100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in y around inf 35.5%
Taylor expanded in z around 0 75.6%
Final simplification72.0%
(FPCore (x y z t) :precision binary64 (if (or (<= y -3.6e-68) (not (<= y 1.1e+32))) (+ x (* z (- t x))) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.6e-68) || !(y <= 1.1e+32)) {
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 <= (-3.6d-68)) .or. (.not. (y <= 1.1d+32))) 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 <= -3.6e-68) || !(y <= 1.1e+32)) {
tmp = x + (z * (t - x));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -3.6e-68) or not (y <= 1.1e+32): tmp = x + (z * (t - x)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -3.6e-68) || !(y <= 1.1e+32)) 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 <= -3.6e-68) || ~((y <= 1.1e+32))) tmp = x + (z * (t - x)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.6e-68], N[Not[LessEqual[y, 1.1e+32]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{-68} \lor \neg \left(y \leq 1.1 \cdot 10^{+32}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -3.60000000000000007e-68 or 1.1e32 < y Initial program 84.6%
associate-*l*93.0%
Simplified93.0%
Taylor expanded in y around inf 81.7%
if -3.60000000000000007e-68 < y < 1.1e32Initial program 100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in y around inf 38.5%
Taylor expanded in z around 0 73.9%
Final simplification78.5%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.02e+191) (not (<= y 5.2e+72))) (* z (- t x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.02e+191) || !(y <= 5.2e+72)) {
tmp = 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 <= (-1.02d+191)) .or. (.not. (y <= 5.2d+72))) then
tmp = 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 <= -1.02e+191) || !(y <= 5.2e+72)) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.02e+191) or not (y <= 5.2e+72): tmp = z * (t - x) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.02e+191) || !(y <= 5.2e+72)) tmp = 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 <= -1.02e+191) || ~((y <= 5.2e+72))) tmp = z * (t - x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.02e+191], N[Not[LessEqual[y, 5.2e+72]], $MachinePrecision]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.02 \cdot 10^{+191} \lor \neg \left(y \leq 5.2 \cdot 10^{+72}\right):\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.02000000000000006e191 or 5.19999999999999963e72 < y Initial program 72.6%
associate-*l*88.7%
Simplified88.7%
Taylor expanded in y around inf 88.0%
Taylor expanded in z around inf 64.1%
if -1.02000000000000006e191 < y < 5.19999999999999963e72Initial program 99.9%
associate-*l*99.5%
Simplified99.5%
Taylor expanded in y around inf 52.0%
Taylor expanded in z around 0 68.8%
Final simplification67.3%
(FPCore (x y z t) :precision binary64 (if (<= z 7e+64) x (* z t)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 7e+64) {
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 (z <= 7d+64) 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 (z <= 7e+64) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 7e+64: tmp = x else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 7e+64) tmp = x; else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 7e+64) tmp = x; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 7e+64], x, N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 7 \cdot 10^{+64}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if z < 6.9999999999999997e64Initial program 93.7%
associate-*l*96.3%
Simplified96.3%
Taylor expanded in y around inf 67.5%
Taylor expanded in z around 0 66.0%
if 6.9999999999999997e64 < z Initial program 81.4%
associate-*l*94.7%
Simplified94.7%
Taylor expanded in y around inf 51.1%
Taylor expanded in x around 0 40.8%
Final simplification60.4%
(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.0%
associate-*l*95.9%
Simplified95.9%
Taylor expanded in y around inf 63.8%
Taylor expanded in z around 0 55.5%
Final simplification55.5%
(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 2023182
(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))))))