
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+306)))
(+ x (* 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+306)) {
tmp = x + (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+306)) {
tmp = x + (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+306): tmp = x + (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+306)) tmp = Float64(x + 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+306))) tmp = x + (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+306]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $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^{+306}\right):\\
\;\;\;\;x + 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 4.99999999999999993e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 47.0%
Taylor expanded in y around inf 100.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.99999999999999993e306Initial program 100.0%
Final simplification100.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.3e+194) (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.3e+194) {
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.3e+194) 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.3e+194], 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.3 \cdot 10^{+194}:\\
\;\;\;\;\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.2999999999999999e194Initial program 94.7%
+-commutative94.7%
associate-*l*98.7%
fma-def98.7%
Simplified98.7%
if 1.2999999999999999e194 < y Initial program 90.8%
Taylor expanded in y around inf 95.9%
Final simplification98.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 3.4e+34)
(+ x (* t_1 (* y z)))
(if (<= y 7e+193) (fma y (* z (- t_1 (/ x y))) x) (+ x (* z (- t x)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 3.4e+34) {
tmp = x + (t_1 * (y * z));
} else if (y <= 7e+193) {
tmp = fma(y, (z * (t_1 - (x / y))), x);
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 3.4e+34) tmp = Float64(x + Float64(t_1 * Float64(y * z))); elseif (y <= 7e+193) tmp = fma(y, Float64(z * Float64(t_1 - Float64(x / y))), x); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 3.4e+34], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e+193], N[(y * N[(z * N[(t$95$1 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $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)\\
\mathbf{if}\;y \leq 3.4 \cdot 10^{+34}:\\
\;\;\;\;x + t_1 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+193}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \left(t_1 - \frac{x}{y}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.3999999999999999e34Initial program 95.3%
Taylor expanded in x around 0 27.3%
associate-*r*27.1%
associate-/r*27.1%
div-sub27.1%
rec-exp27.1%
rec-exp27.1%
tanh-def-a83.2%
Simplified83.2%
if 3.3999999999999999e34 < y < 7.00000000000000026e193Initial program 90.9%
+-commutative90.9%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around 0 91.9%
if 7.00000000000000026e193 < y Initial program 90.8%
Taylor expanded in y around inf 95.9%
Final simplification85.3%
(FPCore (x y z t) :precision binary64 (if (or (<= y 1.75e+44) (and (not (<= y 3.7e+77)) (<= y 1.25e+132))) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 1.75e+44) || (!(y <= 3.7e+77) && (y <= 1.25e+132))) {
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 <= 1.75d+44) .or. (.not. (y <= 3.7d+77)) .and. (y <= 1.25d+132)) 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 <= 1.75e+44) || (!(y <= 3.7e+77) && (y <= 1.25e+132))) {
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 <= 1.75e+44) or (not (y <= 3.7e+77) and (y <= 1.25e+132)): 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 <= 1.75e+44) || (!(y <= 3.7e+77) && (y <= 1.25e+132))) 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 <= 1.75e+44) || (~((y <= 3.7e+77)) && (y <= 1.25e+132))) tmp = x + (tanh((t / y)) * (y * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, 1.75e+44], And[N[Not[LessEqual[y, 3.7e+77]], $MachinePrecision], LessEqual[y, 1.25e+132]]], 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 1.75 \cdot 10^{+44} \lor \neg \left(y \leq 3.7 \cdot 10^{+77}\right) \land y \leq 1.25 \cdot 10^{+132}:\\
\;\;\;\;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 < 1.75e44 or 3.69999999999999995e77 < y < 1.25e132Initial program 95.0%
Taylor expanded in x around 0 27.6%
associate-*r*27.4%
associate-/r*27.4%
div-sub27.4%
rec-exp27.4%
rec-exp27.4%
tanh-def-a83.0%
Simplified83.0%
if 1.75e44 < y < 3.69999999999999995e77 or 1.25e132 < y Initial program 91.2%
Taylor expanded in y around inf 86.1%
Final simplification83.5%
(FPCore (x y z t) :precision binary64 (if (<= y 1.75e+38) x (if (<= y 1e+78) (* x (- 1.0 z)) (if (<= y 3.6e+98) x (+ x (* z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.75e+38) {
tmp = x;
} else if (y <= 1e+78) {
tmp = x * (1.0 - z);
} else if (y <= 3.6e+98) {
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 <= 1.75d+38) then
tmp = x
else if (y <= 1d+78) then
tmp = x * (1.0d0 - z)
else if (y <= 3.6d+98) 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 <= 1.75e+38) {
tmp = x;
} else if (y <= 1e+78) {
tmp = x * (1.0 - z);
} else if (y <= 3.6e+98) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.75e+38: tmp = x elif y <= 1e+78: tmp = x * (1.0 - z) elif y <= 3.6e+98: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.75e+38) tmp = x; elseif (y <= 1e+78) tmp = Float64(x * Float64(1.0 - z)); elseif (y <= 3.6e+98) 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 <= 1.75e+38) tmp = x; elseif (y <= 1e+78) tmp = x * (1.0 - z); elseif (y <= 3.6e+98) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.75e+38], x, If[LessEqual[y, 1e+78], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e+98], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.75 \cdot 10^{+38}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 10^{+78}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+98}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.75000000000000001e38 or 1.00000000000000001e78 < y < 3.59999999999999981e98Initial program 95.4%
+-commutative95.4%
associate-*l*98.6%
fma-def98.6%
Simplified98.6%
Taylor expanded in y around 0 70.1%
if 1.75000000000000001e38 < y < 1.00000000000000001e78Initial program 99.6%
+-commutative99.6%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 86.4%
Taylor expanded in x around inf 63.2%
mul-1-neg63.2%
neg-sub063.2%
metadata-eval63.2%
associate-+r-63.2%
metadata-eval63.2%
metadata-eval63.2%
Simplified63.2%
if 3.59999999999999981e98 < y Initial program 89.3%
Taylor expanded in x around 0 39.7%
associate-*r*39.4%
associate-/r*39.4%
div-sub39.4%
rec-exp39.4%
rec-exp39.4%
tanh-def-a77.7%
Simplified77.7%
Taylor expanded in y around inf 67.3%
+-commutative67.3%
*-commutative67.3%
Simplified67.3%
Final simplification69.5%
(FPCore (x y z t) :precision binary64 (if (<= y 1.46e+37) x (if (<= y 1.22e+79) (- x (* z x)) (if (<= y 1.1e+99) x (+ x (* z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.46e+37) {
tmp = x;
} else if (y <= 1.22e+79) {
tmp = x - (z * x);
} else if (y <= 1.1e+99) {
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 <= 1.46d+37) then
tmp = x
else if (y <= 1.22d+79) then
tmp = x - (z * x)
else if (y <= 1.1d+99) 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 <= 1.46e+37) {
tmp = x;
} else if (y <= 1.22e+79) {
tmp = x - (z * x);
} else if (y <= 1.1e+99) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.46e+37: tmp = x elif y <= 1.22e+79: tmp = x - (z * x) elif y <= 1.1e+99: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.46e+37) tmp = x; elseif (y <= 1.22e+79) tmp = Float64(x - Float64(z * x)); elseif (y <= 1.1e+99) 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 <= 1.46e+37) tmp = x; elseif (y <= 1.22e+79) tmp = x - (z * x); elseif (y <= 1.1e+99) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.46e+37], x, If[LessEqual[y, 1.22e+79], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+99], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.46 \cdot 10^{+37}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.22 \cdot 10^{+79}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+99}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.4599999999999999e37 or 1.22000000000000002e79 < y < 1.09999999999999989e99Initial program 95.4%
+-commutative95.4%
associate-*l*98.6%
fma-def98.6%
Simplified98.6%
Taylor expanded in y around 0 70.1%
if 1.4599999999999999e37 < y < 1.22000000000000002e79Initial program 99.6%
Taylor expanded in y around inf 86.0%
Taylor expanded in t around 0 62.8%
mul-1-neg62.8%
distribute-frac-neg62.8%
Simplified62.8%
clear-num62.8%
un-div-inv63.2%
add-sqr-sqrt61.4%
sqrt-unprod40.3%
sqr-neg40.3%
sqrt-unprod1.7%
add-sqr-sqrt27.6%
Applied egg-rr27.6%
frac-2neg27.6%
distribute-frac-neg27.6%
add-sqr-sqrt26.7%
sqrt-unprod63.2%
sqr-neg63.2%
sqrt-unprod36.0%
add-sqr-sqrt63.2%
distribute-rgt-neg-in63.2%
frac-2neg63.2%
sub-neg63.2%
associate-/r/63.2%
*-commutative63.2%
div-inv63.2%
add-sqr-sqrt26.7%
sqrt-unprod27.6%
sqr-neg27.6%
sqrt-unprod0.9%
add-sqr-sqrt27.6%
associate-*l*27.6%
associate-*l*27.6%
Applied egg-rr63.2%
*-commutative63.2%
*-commutative63.2%
associate-/l*63.2%
*-inverses63.2%
/-rgt-identity63.2%
Simplified63.2%
if 1.09999999999999989e99 < y Initial program 89.3%
Taylor expanded in x around 0 39.7%
associate-*r*39.4%
associate-/r*39.4%
div-sub39.4%
rec-exp39.4%
rec-exp39.4%
tanh-def-a77.7%
Simplified77.7%
Taylor expanded in y around inf 67.3%
+-commutative67.3%
*-commutative67.3%
Simplified67.3%
Final simplification69.5%
(FPCore (x y z t) :precision binary64 (if (<= y 1.5e+39) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.5e+39) {
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.5d+39) 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.5e+39) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.5e+39: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.5e+39) 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.5e+39) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.5e+39], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{+39}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.5e39Initial program 95.3%
+-commutative95.3%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in y around 0 69.9%
if 1.5e39 < y Initial program 90.9%
Taylor expanded in y around inf 84.7%
Final simplification73.0%
(FPCore (x y z t) :precision binary64 (if (<= x -3.7e-160) x (if (<= x -7.5e-257) (* z t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -3.7e-160) {
tmp = x;
} else if (x <= -7.5e-257) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (x <= (-3.7d-160)) then
tmp = x
else if (x <= (-7.5d-257)) then
tmp = z * t
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -3.7e-160) {
tmp = x;
} else if (x <= -7.5e-257) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -3.7e-160: tmp = x elif x <= -7.5e-257: tmp = z * t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -3.7e-160) tmp = x; elseif (x <= -7.5e-257) tmp = Float64(z * t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -3.7e-160) tmp = x; elseif (x <= -7.5e-257) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -3.7e-160], x, If[LessEqual[x, -7.5e-257], N[(z * t), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.7 \cdot 10^{-160}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -7.5 \cdot 10^{-257}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -3.69999999999999977e-160 or -7.4999999999999995e-257 < x Initial program 96.3%
+-commutative96.3%
associate-*l*99.1%
fma-def99.1%
Simplified99.1%
Taylor expanded in y around 0 70.8%
if -3.69999999999999977e-160 < x < -7.4999999999999995e-257Initial program 74.5%
Taylor expanded in x around 0 2.9%
associate-*r*2.3%
associate-/r*2.3%
div-sub2.3%
rec-exp2.4%
rec-exp2.4%
tanh-def-a66.0%
Simplified66.0%
Taylor expanded in y around inf 45.5%
+-commutative45.5%
*-commutative45.5%
Simplified45.5%
Taylor expanded in z around inf 45.3%
*-commutative45.3%
Simplified45.3%
Final simplification68.5%
(FPCore (x y z t) :precision binary64 (if (<= y 8.6e+37) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.6e+37) {
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 <= 8.6d+37) 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 <= 8.6e+37) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8.6e+37: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8.6e+37) 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 <= 8.6e+37) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.6e+37], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.6 \cdot 10^{+37}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 8.5999999999999994e37Initial program 95.3%
+-commutative95.3%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in y around 0 69.9%
if 8.5999999999999994e37 < y Initial program 90.9%
+-commutative90.9%
associate-*l*92.5%
fma-def92.5%
Simplified92.5%
Taylor expanded in x around 0 87.9%
Taylor expanded in x around inf 62.6%
mul-1-neg62.6%
neg-sub062.6%
metadata-eval62.6%
associate-+r-62.6%
metadata-eval62.6%
metadata-eval62.6%
Simplified62.6%
Final simplification68.4%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 94.4%
+-commutative94.4%
associate-*l*97.3%
fma-def97.3%
Simplified97.3%
Taylor expanded in y around 0 65.1%
Final simplification65.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 2023336
(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))))))