
(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 (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 92.1%
+-commutative92.1%
associate-*l*97.1%
fma-def97.2%
Simplified97.2%
Final simplification97.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}
Initial program 92.1%
associate-*l*97.1%
Simplified97.1%
Final simplification97.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -7.5e-13) (not (<= t 4.5e-132))) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t (* y (tanh (/ x y))))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -7.5e-13) || !(t <= 4.5e-132)) {
tmp = x + (y * (z * tanh((t / y))));
} else {
tmp = x + (z * (t - (y * tanh((x / y)))));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-7.5d-13)) .or. (.not. (t <= 4.5d-132))) then
tmp = x + (y * (z * tanh((t / y))))
else
tmp = x + (z * (t - (y * tanh((x / y)))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -7.5e-13) || !(t <= 4.5e-132)) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + (z * (t - (y * Math.tanh((x / y)))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -7.5e-13) or not (t <= 4.5e-132): tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + (z * (t - (y * math.tanh((x / y))))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -7.5e-13) || !(t <= 4.5e-132)) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); else tmp = Float64(x + Float64(z * Float64(t - Float64(y * tanh(Float64(x / y)))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -7.5e-13) || ~((t <= 4.5e-132))) tmp = x + (y * (z * tanh((t / y)))); else tmp = x + (z * (t - (y * tanh((x / y))))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -7.5e-13], N[Not[LessEqual[t, 4.5e-132]], $MachinePrecision]], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - N[(y * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.5 \cdot 10^{-13} \lor \neg \left(t \leq 4.5 \cdot 10^{-132}\right):\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - y \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -7.5000000000000004e-13 or 4.4999999999999999e-132 < t Initial program 95.2%
associate-*l*99.1%
Simplified99.1%
Taylor expanded in x around 0 13.0%
associate-/r*13.0%
div-sub13.0%
rec-exp13.0%
rec-exp13.0%
tanh-def-a85.0%
Simplified85.0%
if -7.5000000000000004e-13 < t < 4.4999999999999999e-132Initial program 87.1%
Taylor expanded in t around 0 82.7%
Taylor expanded in t around -inf 28.1%
+-commutative28.1%
mul-1-neg28.1%
unsub-neg28.1%
*-commutative28.1%
Simplified92.2%
Taylor expanded in z around 0 28.1%
cancel-sign-sub-inv28.1%
associate-/r*28.1%
div-sub28.1%
Simplified92.2%
Final simplification87.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 2.05e-221)
x
(if (<= y 6.6e+84) (+ x (* y (* z t_1))) (+ x (* z (- (* y t_1) x)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 2.05e-221) {
tmp = x;
} else if (y <= 6.6e+84) {
tmp = x + (y * (z * t_1));
} else {
tmp = x + (z * ((y * 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 = tanh((t / y))
if (y <= 2.05d-221) then
tmp = x
else if (y <= 6.6d+84) then
tmp = x + (y * (z * t_1))
else
tmp = x + (z * ((y * t_1) - x))
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 <= 2.05e-221) {
tmp = x;
} else if (y <= 6.6e+84) {
tmp = x + (y * (z * t_1));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 2.05e-221: tmp = x elif y <= 6.6e+84: tmp = x + (y * (z * t_1)) else: tmp = x + (z * ((y * t_1) - x)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 2.05e-221) tmp = x; elseif (y <= 6.6e+84) tmp = Float64(x + Float64(y * Float64(z * t_1))); else tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 2.05e-221) tmp = x; elseif (y <= 6.6e+84) tmp = x + (y * (z * t_1)); else tmp = x + (z * ((y * t_1) - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 2.05e-221], x, If[LessEqual[y, 6.6e+84], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 2.05 \cdot 10^{-221}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{+84}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 2.04999999999999991e-221Initial program 94.0%
+-commutative94.0%
associate-*l*97.1%
fma-def97.1%
Simplified97.1%
Taylor expanded in y around 0 63.5%
if 2.04999999999999991e-221 < y < 6.60000000000000034e84Initial program 99.9%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around 0 22.1%
associate-/r*22.1%
div-sub22.1%
rec-exp22.1%
rec-exp22.1%
tanh-def-a85.7%
Simplified85.7%
if 6.60000000000000034e84 < y Initial program 76.5%
associate-*l*93.9%
Simplified93.9%
Taylor expanded in x around 0 59.1%
+-commutative59.1%
Simplified94.2%
Final simplification74.7%
(FPCore (x y z t) :precision binary64 (if (<= y 3.6e-221) x (if (<= y 1.45e+111) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.6e-221) {
tmp = x;
} else if (y <= 1.45e+111) {
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 <= 3.6d-221) then
tmp = x
else if (y <= 1.45d+111) 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 <= 3.6e-221) {
tmp = x;
} else if (y <= 1.45e+111) {
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 <= 3.6e-221: tmp = x elif y <= 1.45e+111: 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 <= 3.6e-221) tmp = x; elseif (y <= 1.45e+111) 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 <= 3.6e-221) tmp = x; elseif (y <= 1.45e+111) 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, 3.6e-221], x, If[LessEqual[y, 1.45e+111], 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 3.6 \cdot 10^{-221}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+111}:\\
\;\;\;\;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 < 3.60000000000000011e-221Initial program 94.0%
+-commutative94.0%
associate-*l*97.1%
fma-def97.1%
Simplified97.1%
Taylor expanded in y around 0 63.5%
if 3.60000000000000011e-221 < y < 1.45e111Initial program 99.9%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around 0 20.7%
associate-/r*20.7%
div-sub20.7%
rec-exp20.7%
rec-exp20.7%
tanh-def-a83.0%
Simplified83.0%
if 1.45e111 < y Initial program 73.4%
associate-*l*93.1%
Simplified93.1%
Taylor expanded in y around inf 89.2%
Final simplification72.9%
(FPCore (x y z t)
:precision binary64
(if (<= y 6.2e+84)
x
(if (or (<= y 2.1e+180) (not (<= y 2.5e+296)))
(* x (- 1.0 z))
(+ x (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.2e+84) {
tmp = x;
} else if ((y <= 2.1e+180) || !(y <= 2.5e+296)) {
tmp = x * (1.0 - z);
} 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 <= 6.2d+84) then
tmp = x
else if ((y <= 2.1d+180) .or. (.not. (y <= 2.5d+296))) then
tmp = x * (1.0d0 - z)
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 <= 6.2e+84) {
tmp = x;
} else if ((y <= 2.1e+180) || !(y <= 2.5e+296)) {
tmp = x * (1.0 - z);
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 6.2e+84: tmp = x elif (y <= 2.1e+180) or not (y <= 2.5e+296): tmp = x * (1.0 - z) else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 6.2e+84) tmp = x; elseif ((y <= 2.1e+180) || !(y <= 2.5e+296)) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 6.2e+84) tmp = x; elseif ((y <= 2.1e+180) || ~((y <= 2.5e+296))) tmp = x * (1.0 - z); else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.2e+84], x, If[Or[LessEqual[y, 2.1e+180], N[Not[LessEqual[y, 2.5e+296]], $MachinePrecision]], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{+84}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+180} \lor \neg \left(y \leq 2.5 \cdot 10^{+296}\right):\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 6.20000000000000006e84Initial program 95.8%
+-commutative95.8%
associate-*l*97.9%
fma-def97.9%
Simplified97.9%
Taylor expanded in y around 0 65.4%
if 6.20000000000000006e84 < y < 2.1e180 or 2.5e296 < y Initial program 82.0%
associate-*l*96.8%
Simplified96.8%
Taylor expanded in y around inf 79.5%
Taylor expanded in x around inf 79.2%
mul-1-neg79.2%
unsub-neg79.2%
Simplified79.2%
if 2.1e180 < y < 2.5e296Initial program 66.3%
associate-*l*88.6%
Simplified88.6%
Taylor expanded in x around 0 28.4%
associate-/r*28.4%
div-sub28.4%
rec-exp28.4%
rec-exp28.4%
tanh-def-a71.9%
Simplified71.9%
Taylor expanded in y around inf 77.6%
+-commutative77.6%
*-commutative77.6%
Simplified77.6%
Final simplification67.9%
(FPCore (x y z t) :precision binary64 (if (<= y 1.35e+72) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.35e+72) {
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.35d+72) 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.35e+72) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.35e+72: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.35e+72) 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.35e+72) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.35e+72], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+72}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.35e72Initial program 95.6%
+-commutative95.6%
associate-*l*97.9%
fma-def97.9%
Simplified97.9%
Taylor expanded in y around 0 66.0%
if 1.35e72 < y Initial program 78.7%
associate-*l*94.5%
Simplified94.5%
Taylor expanded in y around inf 81.0%
Final simplification69.2%
(FPCore (x y z t) :precision binary64 (if (<= y 6.5e+84) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.5e+84) {
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 <= 6.5d+84) 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 <= 6.5e+84) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 6.5e+84: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 6.5e+84) 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 <= 6.5e+84) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.5e+84], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{+84}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 6.50000000000000027e84Initial program 95.8%
+-commutative95.8%
associate-*l*97.9%
fma-def97.9%
Simplified97.9%
Taylor expanded in y around 0 65.4%
if 6.50000000000000027e84 < y Initial program 76.5%
associate-*l*93.9%
Simplified93.9%
Taylor expanded in y around inf 84.7%
Taylor expanded in x around inf 69.0%
mul-1-neg69.0%
unsub-neg69.0%
Simplified69.0%
Final simplification66.1%
(FPCore (x y z t) :precision binary64 (if (<= z 2.35e+249) x (* z (- x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 2.35e+249) {
tmp = x;
} else {
tmp = z * -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 <= 2.35d+249) then
tmp = x
else
tmp = z * -x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 2.35e+249) {
tmp = x;
} else {
tmp = z * -x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 2.35e+249: tmp = x else: tmp = z * -x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 2.35e+249) tmp = x; else tmp = Float64(z * Float64(-x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 2.35e+249) tmp = x; else tmp = z * -x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 2.35e+249], x, N[(z * (-x)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.35 \cdot 10^{+249}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\end{array}
\end{array}
if z < 2.3499999999999998e249Initial program 92.5%
+-commutative92.5%
associate-*l*97.0%
fma-def97.0%
Simplified97.0%
Taylor expanded in y around 0 61.2%
if 2.3499999999999998e249 < z Initial program 85.0%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in y around inf 62.9%
Taylor expanded in x around inf 54.9%
mul-1-neg54.9%
unsub-neg54.9%
Simplified54.9%
Taylor expanded in z around inf 54.9%
mul-1-neg54.9%
*-commutative54.9%
distribute-rgt-neg-in54.9%
Simplified54.9%
Final simplification60.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 92.1%
+-commutative92.1%
associate-*l*97.1%
fma-def97.2%
Simplified97.2%
Taylor expanded in y around 0 59.3%
Final simplification59.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 2023310
(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))))))