
(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 13 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)) 5e+297)
(fma z (* y t_1) x)
(+ x (* z (- t x))))))
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)) <= 5e+297) {
tmp = fma(z, (y * t_1), x);
} else {
tmp = x + (z * (t - x));
}
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)) <= 5e+297) tmp = fma(z, Float64(y * t_1), x); else tmp = Float64(x + Float64(z * Float64(t - x))); end return 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], 5e+297], N[(z * N[(y * t$95$1), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $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 5 \cdot 10^{+297}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot t_1, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.9999999999999998e297Initial program 97.1%
+-commutative97.1%
*-commutative97.1%
associate-*l*98.7%
fma-def98.7%
Simplified98.7%
if 4.9999999999999998e297 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 42.8%
+-commutative42.8%
*-commutative42.8%
associate-*l*65.7%
fma-def65.7%
Simplified65.7%
Taylor expanded in y around inf 100.0%
Final simplification98.8%
(FPCore (x y z t) :precision binary64 (if (<= y 2.4e+195) (+ x (* y (- (* z (tanh (/ t y))) (* z (tanh (/ x y)))))) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.4e+195) {
tmp = x + (y * ((z * tanh((t / y))) - (z * tanh((x / y)))));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 2.4e+195) tmp = Float64(x + Float64(y * Float64(Float64(z * tanh(Float64(t / y))) - Float64(z * tanh(Float64(x / y)))))); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.4e+195], 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], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4 \cdot 10^{+195}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right) - z \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 2.4000000000000003e195Initial program 94.1%
associate-*l*96.2%
Simplified96.2%
sub-neg96.2%
distribute-rgt-in96.2%
Applied egg-rr96.2%
if 2.4000000000000003e195 < y Initial program 87.0%
associate-*l*94.1%
Simplified94.1%
Taylor expanded in y around inf 99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Final simplification96.5%
(FPCore (x y z t) :precision binary64 (if (<= y 1.1e+195) (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.1e+195) {
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.1e+195) tmp = Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.1e+195], 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[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{+195}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.1e195Initial program 94.1%
associate-*l*96.2%
Simplified96.2%
if 1.1e195 < y Initial program 87.0%
associate-*l*94.1%
Simplified94.1%
Taylor expanded in y around inf 99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Final simplification96.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (tanh (/ t y))))) (if (<= y 3.7e+48) (fma z t_1 x) (fma z (- t_1 x) x))))
double code(double x, double y, double z, double t) {
double t_1 = y * tanh((t / y));
double tmp;
if (y <= 3.7e+48) {
tmp = fma(z, t_1, x);
} else {
tmp = fma(z, (t_1 - x), x);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * tanh(Float64(t / y))) tmp = 0.0 if (y <= 3.7e+48) tmp = fma(z, t_1, x); else tmp = fma(z, Float64(t_1 - x), x); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 3.7e+48], N[(z * t$95$1 + x), $MachinePrecision], N[(z * N[(t$95$1 - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 3.7 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(z, t_1, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t_1 - x, x\right)\\
\end{array}
\end{array}
if y < 3.6999999999999999e48Initial program 94.2%
+-commutative94.2%
*-commutative94.2%
associate-*l*96.2%
fma-def96.2%
Simplified96.2%
Taylor expanded in x around 0 21.7%
associate-/r*21.7%
div-sub21.7%
rec-exp21.7%
rec-exp21.7%
tanh-def-a81.0%
Simplified81.0%
if 3.6999999999999999e48 < y Initial program 90.5%
+-commutative90.5%
*-commutative90.5%
associate-*l*98.1%
fma-def98.1%
Simplified98.1%
Taylor expanded in x around 0 70.7%
neg-mul-170.7%
+-commutative70.7%
unsub-neg70.7%
Simplified96.1%
Final simplification83.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (tanh (/ t y))))) (if (<= y 2.5e+47) (fma z t_1 x) (+ x (* z (- t_1 x))))))
double code(double x, double y, double z, double t) {
double t_1 = y * tanh((t / y));
double tmp;
if (y <= 2.5e+47) {
tmp = fma(z, t_1, x);
} else {
tmp = x + (z * (t_1 - x));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * tanh(Float64(t / y))) tmp = 0.0 if (y <= 2.5e+47) tmp = fma(z, t_1, x); else tmp = Float64(x + Float64(z * Float64(t_1 - x))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 2.5e+47], N[(z * t$95$1 + x), $MachinePrecision], N[(x + N[(z * N[(t$95$1 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 2.5 \cdot 10^{+47}:\\
\;\;\;\;\mathsf{fma}\left(z, t_1, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t_1 - x\right)\\
\end{array}
\end{array}
if y < 2.50000000000000011e47Initial program 94.2%
+-commutative94.2%
*-commutative94.2%
associate-*l*96.2%
fma-def96.2%
Simplified96.2%
Taylor expanded in x around 0 21.7%
associate-/r*21.7%
div-sub21.7%
rec-exp21.7%
rec-exp21.7%
tanh-def-a81.0%
Simplified81.0%
if 2.50000000000000011e47 < y Initial program 90.5%
Taylor expanded in x around 0 86.6%
Taylor expanded in y around 0 70.7%
mul-1-neg70.7%
unsub-neg70.7%
Simplified86.4%
Taylor expanded in z around 0 70.7%
*-commutative70.7%
Simplified96.1%
Final simplification83.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (tanh (/ t y))))) (if (<= y 6.5e+47) (+ x (* z t_1)) (+ x (* z (- t_1 x))))))
double code(double x, double y, double z, double t) {
double t_1 = y * tanh((t / y));
double tmp;
if (y <= 6.5e+47) {
tmp = x + (z * t_1);
} else {
tmp = x + (z * (t_1 - 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) :: t_1
real(8) :: tmp
t_1 = y * tanh((t / y))
if (y <= 6.5d+47) then
tmp = x + (z * t_1)
else
tmp = x + (z * (t_1 - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y * Math.tanh((t / y));
double tmp;
if (y <= 6.5e+47) {
tmp = x + (z * t_1);
} else {
tmp = x + (z * (t_1 - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = y * math.tanh((t / y)) tmp = 0 if y <= 6.5e+47: tmp = x + (z * t_1) else: tmp = x + (z * (t_1 - x)) return tmp
function code(x, y, z, t) t_1 = Float64(y * tanh(Float64(t / y))) tmp = 0.0 if (y <= 6.5e+47) tmp = Float64(x + Float64(z * t_1)); else tmp = Float64(x + Float64(z * Float64(t_1 - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * tanh((t / y)); tmp = 0.0; if (y <= 6.5e+47) tmp = x + (z * t_1); else tmp = x + (z * (t_1 - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 6.5e+47], N[(x + N[(z * t$95$1), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t$95$1 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 6.5 \cdot 10^{+47}:\\
\;\;\;\;x + z \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t_1 - x\right)\\
\end{array}
\end{array}
if y < 6.49999999999999988e47Initial program 94.2%
+-commutative94.2%
*-commutative94.2%
associate-*l*96.2%
fma-def96.2%
Simplified96.2%
Taylor expanded in x around 0 21.7%
associate-/r*21.7%
div-sub21.7%
rec-exp21.7%
rec-exp21.7%
tanh-def-a81.0%
Simplified81.0%
fma-udef81.0%
Applied egg-rr81.0%
if 6.49999999999999988e47 < y Initial program 90.5%
Taylor expanded in x around 0 86.6%
Taylor expanded in y around 0 70.7%
mul-1-neg70.7%
unsub-neg70.7%
Simplified86.4%
Taylor expanded in z around 0 70.7%
*-commutative70.7%
Simplified96.1%
Final simplification83.9%
(FPCore (x y z t) :precision binary64 (if (<= y 7.8e+48) (+ 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 <= 7.8e+48) {
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 <= 7.8e+48) tmp = Float64(x + Float64(Float64(y * 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, 7.8e+48], N[(x + N[(N[(y * z), $MachinePrecision] * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.8 \cdot 10^{+48}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 7.8000000000000002e48Initial program 94.2%
associate-*l*95.7%
Simplified95.7%
Taylor expanded in x around 0 21.7%
*-commutative21.7%
associate-*r*21.6%
associate-/r*21.6%
div-sub21.6%
rec-exp21.6%
rec-exp21.6%
Simplified80.8%
if 7.8000000000000002e48 < y Initial program 90.5%
associate-*l*97.3%
Simplified97.3%
Taylor expanded in y around inf 94.1%
+-commutative94.1%
fma-def94.1%
Simplified94.1%
Final simplification83.4%
(FPCore (x y z t) :precision binary64 (if (<= y 1.26e+48) (+ x (* z (* y (tanh (/ t y))))) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.26e+48) {
tmp = x + (z * (y * tanh((t / y))));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.26e+48) tmp = Float64(x + Float64(z * Float64(y * 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.26e+48], N[(x + N[(z * N[(y * 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.26 \cdot 10^{+48}:\\
\;\;\;\;x + z \cdot \left(y \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.26000000000000001e48Initial program 94.2%
+-commutative94.2%
*-commutative94.2%
associate-*l*96.2%
fma-def96.2%
Simplified96.2%
Taylor expanded in x around 0 21.7%
associate-/r*21.7%
div-sub21.7%
rec-exp21.7%
rec-exp21.7%
tanh-def-a81.0%
Simplified81.0%
fma-udef81.0%
Applied egg-rr81.0%
if 1.26000000000000001e48 < y Initial program 90.5%
associate-*l*97.3%
Simplified97.3%
Taylor expanded in y around inf 94.1%
+-commutative94.1%
fma-def94.1%
Simplified94.1%
Final simplification83.5%
(FPCore (x y z t) :precision binary64 (if (<= y 2.45e+35) x (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.45e+35) {
tmp = x;
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 2.45e+35) tmp = x; else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.45e+35], x, N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.45 \cdot 10^{+35}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 2.45000000000000013e35Initial program 94.1%
associate-*l*95.6%
Simplified95.6%
Taylor expanded in x around inf 67.9%
if 2.45000000000000013e35 < y Initial program 91.0%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in y around inf 90.9%
+-commutative90.9%
fma-def90.9%
Simplified90.9%
Final simplification72.7%
(FPCore (x y z t)
:precision binary64
(if (<= y 1.45e+35)
x
(if (or (<= y 1.04e+226) (not (<= y 1.02e+257)))
(+ x (* z t))
(- x (* x z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.45e+35) {
tmp = x;
} else if ((y <= 1.04e+226) || !(y <= 1.02e+257)) {
tmp = x + (z * t);
} else {
tmp = x - (x * 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.45d+35) then
tmp = x
else if ((y <= 1.04d+226) .or. (.not. (y <= 1.02d+257))) then
tmp = x + (z * t)
else
tmp = x - (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.45e+35) {
tmp = x;
} else if ((y <= 1.04e+226) || !(y <= 1.02e+257)) {
tmp = x + (z * t);
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.45e+35: tmp = x elif (y <= 1.04e+226) or not (y <= 1.02e+257): tmp = x + (z * t) else: tmp = x - (x * z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.45e+35) tmp = x; elseif ((y <= 1.04e+226) || !(y <= 1.02e+257)) tmp = Float64(x + Float64(z * t)); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.45e+35) tmp = x; elseif ((y <= 1.04e+226) || ~((y <= 1.02e+257))) tmp = x + (z * t); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.45e+35], x, If[Or[LessEqual[y, 1.04e+226], N[Not[LessEqual[y, 1.02e+257]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.45 \cdot 10^{+35}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.04 \cdot 10^{+226} \lor \neg \left(y \leq 1.02 \cdot 10^{+257}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < 1.44999999999999997e35Initial program 94.1%
associate-*l*95.6%
Simplified95.6%
Taylor expanded in x around inf 67.9%
if 1.44999999999999997e35 < y < 1.04000000000000002e226 or 1.02e257 < y Initial program 91.8%
+-commutative91.8%
*-commutative91.8%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in y around inf 89.8%
Taylor expanded in t around inf 71.2%
*-commutative71.2%
Simplified71.2%
if 1.04000000000000002e226 < y < 1.02e257Initial program 84.6%
+-commutative84.6%
*-commutative84.6%
associate-*l*84.6%
fma-def84.6%
Simplified84.6%
Taylor expanded in y around inf 100.0%
Taylor expanded in t around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification69.3%
(FPCore (x y z t) :precision binary64 (if (<= y 1.4e+34) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.4e+34) {
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.4d+34) 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.4e+34) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.4e+34: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.4e+34) 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.4e+34) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.4e+34], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{+34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.40000000000000004e34Initial program 94.1%
associate-*l*95.6%
Simplified95.6%
Taylor expanded in x around inf 67.9%
if 1.40000000000000004e34 < y Initial program 91.0%
+-commutative91.0%
*-commutative91.0%
associate-*l*98.2%
fma-def98.2%
Simplified98.2%
Taylor expanded in y around inf 90.9%
Final simplification72.7%
(FPCore (x y z t) :precision binary64 (if (<= y 8.5e+33) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.5e+33) {
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 <= 8.5d+33) 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 <= 8.5e+33) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8.5e+33: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8.5e+33) 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 <= 8.5e+33) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.5e+33], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{+33}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 8.4999999999999998e33Initial program 94.1%
associate-*l*95.6%
Simplified95.6%
Taylor expanded in x around inf 67.9%
if 8.4999999999999998e33 < y Initial program 91.0%
+-commutative91.0%
*-commutative91.0%
associate-*l*98.2%
fma-def98.2%
Simplified98.2%
Taylor expanded in y around inf 90.9%
Taylor expanded in t around inf 72.7%
*-commutative72.7%
Simplified72.7%
Final simplification68.9%
(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.5%
associate-*l*96.0%
Simplified96.0%
Taylor expanded in x around inf 64.2%
Final simplification64.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 2023224
(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))))))