
(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 (fma y (* z (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(y, (z * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(y, Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(y * N[(z * 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(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 95.8%
+-commutative95.8%
associate-*l*98.4%
fma-define98.4%
Simplified98.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= t -5.2e-91)
(+ x (* y (* z t_1)))
(if (<= t 1.19e-248)
(fma y (* z (- (/ t y) (tanh (/ x y)))) x)
(+ x (* t_1 (* y z)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (t <= -5.2e-91) {
tmp = x + (y * (z * t_1));
} else if (t <= 1.19e-248) {
tmp = fma(y, (z * ((t / y) - tanh((x / y)))), x);
} else {
tmp = x + (t_1 * (y * z));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (t <= -5.2e-91) tmp = Float64(x + Float64(y * Float64(z * t_1))); elseif (t <= 1.19e-248) tmp = fma(y, Float64(z * Float64(Float64(t / y) - tanh(Float64(x / y)))), x); else tmp = Float64(x + Float64(t_1 * Float64(y * z))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -5.2e-91], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.19e-248], N[(y * N[(z * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;t \leq -5.2 \cdot 10^{-91}:\\
\;\;\;\;x + y \cdot \left(z \cdot t\_1\right)\\
\mathbf{elif}\;t \leq 1.19 \cdot 10^{-248}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + t\_1 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if t < -5.20000000000000028e-91Initial program 97.5%
Taylor expanded in x around 0 21.2%
associate-/r*21.2%
div-sub21.2%
rec-exp21.2%
rec-exp21.2%
tanh-def-a91.5%
Simplified91.5%
if -5.20000000000000028e-91 < t < 1.1899999999999999e-248Initial program 94.0%
+-commutative94.0%
associate-*l*95.9%
fma-define96.0%
Simplified96.0%
Taylor expanded in t around 0 94.1%
if 1.1899999999999999e-248 < t Initial program 95.5%
Taylor expanded in x around 0 29.3%
associate-*r*28.9%
associate-/r*28.9%
div-sub28.9%
rec-exp28.9%
rec-exp28.9%
tanh-def-a88.6%
Simplified88.6%
Final simplification90.5%
(FPCore (x y z t) :precision binary64 (if (<= y 2.8e+226) (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.8e+226) {
tmp = x + ((tanh((t / y)) - tanh((x / y))) * (y * z));
} 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 <= 2.8d+226) then
tmp = x + ((tanh((t / y)) - tanh((x / y))) * (y * z))
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 <= 2.8e+226) {
tmp = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.8e+226: tmp = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (y * z)) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.8e+226) tmp = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(y * z))); 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 <= 2.8e+226) tmp = x + ((tanh((t / y)) - tanh((x / y))) * (y * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.8e+226], 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], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{+226}:\\
\;\;\;\;x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.8000000000000003e226Initial program 97.5%
if 2.8000000000000003e226 < y Initial program 74.6%
Taylor expanded in y around inf 95.2%
Final simplification97.3%
(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 95.8%
sub-neg95.8%
distribute-lft-in91.0%
Applied egg-rr91.0%
Taylor expanded in y around 0 15.5%
+-commutative15.5%
Simplified98.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= t -7e-43)
(+ x (* y (* z t_1)))
(if (<= t 1.35e-108)
(- x (* y (* z (tanh (/ x y)))))
(+ x (* t_1 (* y z)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (t <= -7e-43) {
tmp = x + (y * (z * t_1));
} else if (t <= 1.35e-108) {
tmp = x - (y * (z * tanh((x / y))));
} else {
tmp = x + (t_1 * (y * 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) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (t <= (-7d-43)) then
tmp = x + (y * (z * t_1))
else if (t <= 1.35d-108) then
tmp = x - (y * (z * tanh((x / y))))
else
tmp = x + (t_1 * (y * z))
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 <= -7e-43) {
tmp = x + (y * (z * t_1));
} else if (t <= 1.35e-108) {
tmp = x - (y * (z * Math.tanh((x / y))));
} else {
tmp = x + (t_1 * (y * z));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if t <= -7e-43: tmp = x + (y * (z * t_1)) elif t <= 1.35e-108: tmp = x - (y * (z * math.tanh((x / y)))) else: tmp = x + (t_1 * (y * z)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (t <= -7e-43) tmp = Float64(x + Float64(y * Float64(z * t_1))); elseif (t <= 1.35e-108) tmp = Float64(x - Float64(y * Float64(z * tanh(Float64(x / y))))); else tmp = Float64(x + Float64(t_1 * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (t <= -7e-43) tmp = x + (y * (z * t_1)); elseif (t <= 1.35e-108) tmp = x - (y * (z * tanh((x / y)))); else tmp = x + (t_1 * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -7e-43], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.35e-108], N[(x - N[(y * N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;t \leq -7 \cdot 10^{-43}:\\
\;\;\;\;x + y \cdot \left(z \cdot t\_1\right)\\
\mathbf{elif}\;t \leq 1.35 \cdot 10^{-108}:\\
\;\;\;\;x - y \cdot \left(z \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + t\_1 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if t < -6.99999999999999994e-43Initial program 97.0%
Taylor expanded in x around 0 17.2%
associate-/r*17.2%
div-sub17.1%
rec-exp17.1%
rec-exp17.1%
tanh-def-a93.0%
Simplified93.0%
if -6.99999999999999994e-43 < t < 1.35000000000000002e-108Initial program 95.7%
sub-neg95.7%
distribute-lft-in91.2%
Applied egg-rr91.2%
Taylor expanded in t around 0 24.9%
mul-1-neg24.9%
associate-/l*24.9%
associate-/l*24.9%
rec-exp24.9%
rec-exp24.9%
tanh-def-a90.7%
distribute-lft-neg-in90.7%
Simplified90.7%
if 1.35000000000000002e-108 < t Initial program 95.1%
Taylor expanded in x around 0 17.8%
associate-*r*17.4%
associate-/r*17.4%
div-sub17.4%
rec-exp17.4%
rec-exp17.4%
tanh-def-a88.7%
Simplified88.7%
Final simplification90.5%
(FPCore (x y z t) :precision binary64 (if (<= y 2.8e+226) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.8e+226) {
tmp = x + (tanh((t / y)) * (y * z));
} 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 <= 2.8d+226) then
tmp = x + (tanh((t / y)) * (y * z))
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 <= 2.8e+226) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.8e+226: tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.8e+226) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); 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 <= 2.8e+226) tmp = x + (tanh((t / y)) * (y * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.8e+226], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{+226}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.8000000000000003e226Initial program 97.5%
Taylor expanded in x around 0 30.6%
associate-*r*30.3%
associate-/r*30.3%
div-sub30.3%
rec-exp30.3%
rec-exp30.3%
tanh-def-a84.5%
Simplified84.5%
if 2.8000000000000003e226 < y Initial program 74.6%
Taylor expanded in y around inf 95.2%
Final simplification85.3%
(FPCore (x y z t) :precision binary64 (if (<= y 4.9e+165) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.9e+165) {
tmp = x + (y * (z * tanh((t / y))));
} 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 <= 4.9d+165) then
tmp = x + (y * (z * tanh((t / y))))
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 <= 4.9e+165) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 4.9e+165: tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 4.9e+165) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); 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 <= 4.9e+165) tmp = x + (y * (z * tanh((t / y)))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.9e+165], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.9 \cdot 10^{+165}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.89999999999999986e165Initial program 97.8%
Taylor expanded in x around 0 31.5%
associate-/r*31.5%
div-sub31.5%
rec-exp31.5%
rec-exp31.5%
tanh-def-a83.6%
Simplified83.6%
if 4.89999999999999986e165 < y Initial program 80.2%
Taylor expanded in y around inf 90.5%
(FPCore (x y z t) :precision binary64 (if (<= y 5.2e-26) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.2e-26) {
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 <= 5.2d-26) 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 <= 5.2e-26) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 5.2e-26: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 5.2e-26) 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 <= 5.2e-26) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 5.2e-26], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.2 \cdot 10^{-26}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 5.2000000000000002e-26Initial program 98.4%
+-commutative98.4%
associate-*l*98.9%
fma-define98.9%
Simplified98.9%
Taylor expanded in y around 0 73.9%
if 5.2000000000000002e-26 < y Initial program 89.3%
Taylor expanded in y around inf 72.8%
(FPCore (x y z t) :precision binary64 (if (<= y 47000000.0) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 47000000.0) {
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 <= 47000000.0d0) 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 <= 47000000.0) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 47000000.0: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 47000000.0) 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 <= 47000000.0) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 47000000.0], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 47000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 4.7e7Initial program 98.5%
+-commutative98.5%
associate-*l*98.9%
fma-define98.9%
Simplified98.9%
Taylor expanded in y around 0 73.8%
if 4.7e7 < y Initial program 88.2%
Taylor expanded in x around 0 37.3%
associate-*r*36.9%
associate-/r*36.9%
div-sub36.8%
rec-exp36.8%
rec-exp36.8%
tanh-def-a77.9%
Simplified77.9%
Taylor expanded in y around inf 67.7%
*-commutative67.7%
Simplified67.7%
(FPCore (x y z t) :precision binary64 (if (<= y 1.16e+163) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.16e+163) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 1.16d+163) then
tmp = x
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.16e+163) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.16e+163: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.16e+163) tmp = x; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.16e+163) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.16e+163], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.16 \cdot 10^{+163}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 1.16000000000000002e163Initial program 97.8%
+-commutative97.8%
associate-*l*99.1%
fma-define99.1%
Simplified99.1%
Taylor expanded in y around 0 70.8%
if 1.16000000000000002e163 < y Initial program 81.5%
Taylor expanded in y around inf 69.6%
Taylor expanded in x around inf 47.9%
mul-1-neg47.9%
unsub-neg47.9%
Simplified47.9%
(FPCore (x y z t) :precision binary64 (if (<= z -1.35e+118) (* z (- x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.35e+118) {
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 <= (-1.35d+118)) 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 <= -1.35e+118) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.35e+118: tmp = z * -x else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.35e+118) 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 <= -1.35e+118) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.35e+118], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+118}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.35e118Initial program 91.9%
Taylor expanded in y around inf 50.9%
Taylor expanded in x around inf 39.2%
mul-1-neg39.2%
unsub-neg39.2%
Simplified39.2%
Taylor expanded in z around inf 39.2%
neg-mul-139.2%
distribute-lft-neg-in39.2%
*-commutative39.2%
Simplified39.2%
if -1.35e118 < z Initial program 96.4%
+-commutative96.4%
associate-*l*98.6%
fma-define98.6%
Simplified98.6%
Taylor expanded in y around 0 72.7%
(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 95.8%
+-commutative95.8%
associate-*l*98.4%
fma-define98.4%
Simplified98.4%
Taylor expanded in y around 0 66.1%
(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))))))