
(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 12 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 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z))))) (if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+307))) (* z (- t x)) t_1)))
double code(double x, double y, double z, double t) {
double t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+307)) {
tmp = z * (t - x);
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (y * z));
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e+307)) {
tmp = z * (t - x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (y * z)) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 5e+307): tmp = z * (t - x) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(y * z))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+307)) tmp = Float64(z * Float64(t - x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z)); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 5e+307))) tmp = z * (t - x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+307]], $MachinePrecision]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 5 \cdot 10^{+307}\right):\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 5e307 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 60.0%
+-commutative60.0%
associate-*l*89.4%
fma-define89.4%
Simplified89.4%
Taylor expanded in x around 0 63.9%
fma-define63.9%
mul-1-neg63.9%
associate-/r*63.9%
div-sub63.9%
rec-exp63.9%
Simplified97.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 100.0%
*-commutative100.0%
mul-1-neg100.0%
sub-neg100.0%
Simplified100.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5e307Initial program 98.8%
Final simplification98.9%
(FPCore (x y z t) :precision binary64 (if (<= y 1.2e+245) (fma y (* z (- (tanh (/ t y)) (tanh (/ x y)))) x) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.2e+245) {
tmp = fma(y, (z * (tanh((t / y)) - tanh((x / y)))), x);
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.2e+245) tmp = fma(y, Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.2e+245], N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{+245}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.1999999999999999e245Initial program 93.4%
+-commutative93.4%
associate-*l*97.3%
fma-define97.3%
Simplified97.3%
if 1.1999999999999999e245 < y Initial program 85.9%
Taylor expanded in y around inf 100.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* z (tanh (/ t y))))) (if (<= y 4.7e-40) (+ x (* y t_1)) (fma y t_1 (* x (- 1.0 z))))))
double code(double x, double y, double z, double t) {
double t_1 = z * tanh((t / y));
double tmp;
if (y <= 4.7e-40) {
tmp = x + (y * t_1);
} else {
tmp = fma(y, t_1, (x * (1.0 - z)));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * tanh(Float64(t / y))) tmp = 0.0 if (y <= 4.7e-40) tmp = Float64(x + Float64(y * t_1)); else tmp = fma(y, t_1, Float64(x * Float64(1.0 - z))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 4.7e-40], N[(x + N[(y * t$95$1), $MachinePrecision]), $MachinePrecision], N[(y * t$95$1 + N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 4.7 \cdot 10^{-40}:\\
\;\;\;\;x + y \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, t\_1, x \cdot \left(1 - z\right)\right)\\
\end{array}
\end{array}
if y < 4.6999999999999999e-40Initial program 93.8%
Taylor expanded in x around 0 29.3%
associate-/r*29.3%
div-sub29.3%
rec-exp29.3%
rec-exp29.3%
tanh-def-a77.4%
Simplified77.4%
if 4.6999999999999999e-40 < y Initial program 91.0%
+-commutative91.0%
associate-*l*94.5%
fma-define94.5%
Simplified94.5%
Taylor expanded in x around 0 54.2%
+-commutative54.2%
fma-define54.2%
Simplified83.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= t -1.45e+25)
(+ x (* t_1 (* y z)))
(if (<= t 2.45e-108)
(+ x (* (* y z) (- (/ t y) (tanh (/ x y)))))
(+ x (* y (* z t_1)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (t <= -1.45e+25) {
tmp = x + (t_1 * (y * z));
} else if (t <= 2.45e-108) {
tmp = x + ((y * z) * ((t / y) - tanh((x / y))));
} else {
tmp = x + (y * (z * t_1));
}
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 (t <= (-1.45d+25)) then
tmp = x + (t_1 * (y * z))
else if (t <= 2.45d-108) then
tmp = x + ((y * z) * ((t / y) - tanh((x / y))))
else
tmp = x + (y * (z * t_1))
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 (t <= -1.45e+25) {
tmp = x + (t_1 * (y * z));
} else if (t <= 2.45e-108) {
tmp = x + ((y * z) * ((t / y) - Math.tanh((x / y))));
} else {
tmp = x + (y * (z * t_1));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if t <= -1.45e+25: tmp = x + (t_1 * (y * z)) elif t <= 2.45e-108: tmp = x + ((y * z) * ((t / y) - math.tanh((x / y)))) else: tmp = x + (y * (z * t_1)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (t <= -1.45e+25) tmp = Float64(x + Float64(t_1 * Float64(y * z))); elseif (t <= 2.45e-108) tmp = Float64(x + Float64(Float64(y * z) * Float64(Float64(t / y) - tanh(Float64(x / y))))); else tmp = Float64(x + Float64(y * Float64(z * t_1))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (t <= -1.45e+25) tmp = x + (t_1 * (y * z)); elseif (t <= 2.45e-108) tmp = x + ((y * z) * ((t / y) - tanh((x / y)))); else tmp = x + (y * (z * t_1)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -1.45e+25], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 2.45e-108], N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;t \leq -1.45 \cdot 10^{+25}:\\
\;\;\;\;x + t\_1 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;t \leq 2.45 \cdot 10^{-108}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot t\_1\right)\\
\end{array}
\end{array}
if t < -1.44999999999999995e25Initial program 96.8%
Taylor expanded in x around 0 17.8%
associate-*r*17.8%
associate-/r*17.8%
div-sub17.8%
rec-exp17.8%
rec-exp17.8%
tanh-def-a85.2%
Simplified85.2%
if -1.44999999999999995e25 < t < 2.4499999999999999e-108Initial program 89.1%
Taylor expanded in t around 0 84.8%
if 2.4499999999999999e-108 < t Initial program 96.2%
Taylor expanded in x around 0 12.4%
associate-/r*12.5%
div-sub12.4%
rec-exp12.4%
rec-exp12.4%
tanh-def-a83.1%
Simplified83.1%
Final simplification84.4%
(FPCore (x y z t) :precision binary64 (if (<= y 1.25e+79) (+ x (* (tanh (/ t y)) (* y z))) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.25e+79) {
tmp = x + (tanh((t / y)) * (y * z));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.25e+79) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.25e+79], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.25 \cdot 10^{+79}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.25e79Initial program 94.5%
Taylor expanded in x around 0 27.6%
associate-*r*27.3%
associate-/r*27.3%
div-sub27.3%
rec-exp27.3%
rec-exp27.3%
tanh-def-a75.3%
Simplified75.3%
if 1.25e79 < y Initial program 87.4%
+-commutative87.4%
associate-*l*92.3%
fma-define92.3%
Simplified92.3%
Taylor expanded in y around inf 88.4%
+-commutative88.4%
fma-define88.4%
Simplified88.4%
Final simplification78.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.1e+77) (+ x (* y (* z (tanh (/ t y))))) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.1e+77) {
tmp = x + (y * (z * tanh((t / y))));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.1e+77) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.1e+77], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{+77}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.1e77Initial program 94.5%
Taylor expanded in x around 0 27.6%
associate-/r*27.6%
div-sub27.6%
rec-exp27.6%
rec-exp27.6%
tanh-def-a74.7%
Simplified74.7%
if 1.1e77 < y Initial program 87.4%
+-commutative87.4%
associate-*l*92.3%
fma-define92.3%
Simplified92.3%
Taylor expanded in y around inf 88.4%
+-commutative88.4%
fma-define88.4%
Simplified88.4%
(FPCore (x y z t) :precision binary64 (if (<= y 3.8e-27) x (+ (* x (- 1.0 z)) (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.8e-27) {
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.8d-27) 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.8e-27) {
tmp = x;
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.8e-27: tmp = x else: tmp = (x * (1.0 - z)) + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.8e-27) 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.8e-27) tmp = x; else tmp = (x * (1.0 - z)) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.8e-27], 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.8 \cdot 10^{-27}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\
\end{array}
\end{array}
if y < 3.8e-27Initial program 93.9%
+-commutative93.9%
associate-*l*97.5%
fma-define97.5%
Simplified97.5%
Taylor expanded in y around 0 61.7%
if 3.8e-27 < y Initial program 90.9%
+-commutative90.9%
associate-*l*94.4%
fma-define94.4%
Simplified94.4%
Taylor expanded in x around 0 53.6%
fma-define53.6%
mul-1-neg53.6%
associate-/r*53.6%
div-sub53.6%
rec-exp53.6%
Simplified83.3%
Taylor expanded in y around inf 76.6%
Final simplification66.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.9e-29) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.9e-29) {
tmp = x;
} else {
tmp = x + (z * (t - 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.9d-29) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.9e-29) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.9e-29: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.9e-29) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.9e-29) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.9e-29], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{-29}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.89999999999999988e-29Initial program 93.9%
+-commutative93.9%
associate-*l*97.5%
fma-define97.5%
Simplified97.5%
Taylor expanded in y around 0 61.7%
if 1.89999999999999988e-29 < y Initial program 90.9%
Taylor expanded in y around inf 76.5%
(FPCore (x y z t) :precision binary64 (if (<= y 2.7e-18) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.7e-18) {
tmp = x;
} else {
tmp = x + (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 <= 2.7d-18) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.7e-18) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.7e-18: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.7e-18) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.7e-18) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.7e-18], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.7 \cdot 10^{-18}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 2.69999999999999989e-18Initial program 93.9%
+-commutative93.9%
associate-*l*97.5%
fma-define97.5%
Simplified97.5%
Taylor expanded in y around 0 61.6%
if 2.69999999999999989e-18 < y Initial program 90.6%
Taylor expanded in x around 0 34.3%
associate-/r*34.4%
div-sub34.4%
rec-exp34.4%
rec-exp34.4%
tanh-def-a61.3%
Simplified61.3%
Taylor expanded in y around inf 57.0%
*-commutative57.0%
Simplified57.0%
(FPCore (x y z t) :precision binary64 (if (<= y 2.3e-27) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.3e-27) {
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 <= 2.3d-27) 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 <= 2.3e-27) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.3e-27: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.3e-27) 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 <= 2.3e-27) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.3e-27], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.3 \cdot 10^{-27}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 2.2999999999999999e-27Initial program 93.9%
+-commutative93.9%
associate-*l*97.5%
fma-define97.5%
Simplified97.5%
Taylor expanded in y around 0 61.7%
if 2.2999999999999999e-27 < y Initial program 90.9%
+-commutative90.9%
associate-*l*94.4%
fma-define94.4%
Simplified94.4%
Taylor expanded in x around 0 53.6%
fma-define53.6%
mul-1-neg53.6%
associate-/r*53.6%
div-sub53.6%
rec-exp53.6%
Simplified83.3%
Taylor expanded in x around inf 57.6%
(FPCore (x y z t) :precision binary64 (if (<= z -9.4e+83) (* z (- x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9.4e+83) {
tmp = z * -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 (z <= (-9.4d+83)) then
tmp = z * -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 (z <= -9.4e+83) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -9.4e+83: tmp = z * -x else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -9.4e+83) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -9.4e+83) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -9.4e+83], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.4 \cdot 10^{+83}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -9.3999999999999997e83Initial program 86.3%
+-commutative86.3%
associate-*l*93.7%
fma-define93.7%
Simplified93.7%
Taylor expanded in x around 0 37.0%
fma-define37.0%
mul-1-neg37.0%
associate-/r*37.0%
div-sub37.0%
rec-exp37.0%
Simplified67.9%
Taylor expanded in x around inf 41.8%
Taylor expanded in z around inf 41.8%
associate-*r*41.8%
mul-1-neg41.8%
Simplified41.8%
if -9.3999999999999997e83 < z Initial program 94.6%
+-commutative94.6%
associate-*l*97.3%
fma-define97.3%
Simplified97.3%
Taylor expanded in y around 0 60.9%
Final simplification57.2%
(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 93.0%
+-commutative93.0%
associate-*l*96.6%
fma-define96.6%
Simplified96.6%
Taylor expanded in y around 0 54.3%
(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 2024170
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))