
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z))))) (if (<= t_1 1e+299) t_1 (* z (- (+ t (/ x z)) x)))))
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 <= 1e+299) {
tmp = t_1;
} else {
tmp = z * ((t + (x / 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) :: t_1
real(8) :: tmp
t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z))
if (t_1 <= 1d+299) then
tmp = t_1
else
tmp = z * ((t + (x / z)) - x)
end if
code = tmp
end function
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 <= 1e+299) {
tmp = t_1;
} else {
tmp = z * ((t + (x / z)) - x);
}
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 <= 1e+299: tmp = t_1 else: tmp = z * ((t + (x / z)) - x) 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 <= 1e+299) tmp = t_1; else tmp = Float64(z * Float64(Float64(t + Float64(x / z)) - x)); 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 <= 1e+299) tmp = t_1; else tmp = z * ((t + (x / z)) - x); 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[LessEqual[t$95$1, 1e+299], t$95$1, N[(z * N[(N[(t + N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\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 10^{+299}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(\left(t + \frac{x}{z}\right) - x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 1.0000000000000001e299Initial program 98.7%
if 1.0000000000000001e299 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 48.9%
Taylor expanded in y around inf 48.9%
Taylor expanded in z around inf 94.7%
Final simplification98.4%
(FPCore (x y z t) :precision binary64 (fma y (- (* (tanh (/ t y)) z) (* z (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(y, ((tanh((t / y)) * z) - (z * tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(y, Float64(Float64(tanh(Float64(t / y)) * z) - Float64(z * tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(y * N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * z), $MachinePrecision] - N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, \tanh \left(\frac{t}{y}\right) \cdot z - z \cdot \tanh \left(\frac{x}{y}\right), x\right)
\end{array}
Initial program 95.0%
+-commutative95.0%
associate-*l*97.6%
fma-define97.6%
Simplified97.6%
sub-neg97.6%
distribute-rgt-in97.6%
Applied egg-rr97.6%
Final simplification97.6%
(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.0%
+-commutative95.0%
associate-*l*97.6%
fma-define97.6%
Simplified97.6%
(FPCore (x y z t) :precision binary64 (if (or (<= t -2.5e-104) (not (<= t 0.17))) (+ x (* (tanh (/ t y)) (* y z))) (fma y (* z (- (/ t y) (tanh (/ x y)))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.5e-104) || !(t <= 0.17)) {
tmp = x + (tanh((t / y)) * (y * z));
} else {
tmp = fma(y, (z * ((t / y) - tanh((x / y)))), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((t <= -2.5e-104) || !(t <= 0.17)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = fma(y, Float64(z * Float64(Float64(t / y) - tanh(Float64(x / y)))), x); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -2.5e-104], N[Not[LessEqual[t, 0.17]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.5 \cdot 10^{-104} \lor \neg \left(t \leq 0.17\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), x\right)\\
\end{array}
\end{array}
if t < -2.49999999999999989e-104 or 0.170000000000000012 < t Initial program 96.9%
Taylor expanded in x around 0 13.1%
associate-*r*12.9%
associate-/r*12.9%
div-sub12.9%
rec-exp12.9%
rec-exp12.9%
tanh-def-a90.0%
Simplified90.0%
if -2.49999999999999989e-104 < t < 0.170000000000000012Initial program 92.1%
+-commutative92.1%
associate-*l*96.6%
fma-define96.7%
Simplified96.7%
Taylor expanded in t around 0 89.4%
Final simplification89.8%
(FPCore (x y z t) :precision binary64 (if (or (<= x -4.8e+21) (not (<= x 1.05e-52))) (- x (* (tanh (/ x y)) (* y z))) (+ x (* z (- (* y (tanh (/ t y))) x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -4.8e+21) || !(x <= 1.05e-52)) {
tmp = x - (tanh((x / y)) * (y * z));
} else {
tmp = x + (z * ((y * tanh((t / y))) - 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 <= (-4.8d+21)) .or. (.not. (x <= 1.05d-52))) then
tmp = x - (tanh((x / y)) * (y * z))
else
tmp = x + (z * ((y * tanh((t / y))) - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -4.8e+21) || !(x <= 1.05e-52)) {
tmp = x - (Math.tanh((x / y)) * (y * z));
} else {
tmp = x + (z * ((y * Math.tanh((t / y))) - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -4.8e+21) or not (x <= 1.05e-52): tmp = x - (math.tanh((x / y)) * (y * z)) else: tmp = x + (z * ((y * math.tanh((t / y))) - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -4.8e+21) || !(x <= 1.05e-52)) tmp = Float64(x - Float64(tanh(Float64(x / y)) * Float64(y * z))); else tmp = Float64(x + Float64(z * Float64(Float64(y * tanh(Float64(t / y))) - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -4.8e+21) || ~((x <= 1.05e-52))) tmp = x - (tanh((x / y)) * (y * z)); else tmp = x + (z * ((y * tanh((t / y))) - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -4.8e+21], N[Not[LessEqual[x, 1.05e-52]], $MachinePrecision]], N[(x - N[(N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{+21} \lor \neg \left(x \leq 1.05 \cdot 10^{-52}\right):\\
\;\;\;\;x - \tanh \left(\frac{x}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right) - x\right)\\
\end{array}
\end{array}
if x < -4.8e21 or 1.0499999999999999e-52 < x Initial program 97.8%
+-commutative97.8%
associate-*l*100.0%
fma-define100.0%
Simplified100.0%
sub-neg100.0%
distribute-rgt-in100.0%
Applied egg-rr100.0%
Taylor expanded in t around 0 13.5%
mul-1-neg13.5%
unsub-neg13.5%
associate-/l*13.5%
associate-/l*13.5%
rec-exp13.5%
div-sub13.5%
Simplified89.2%
if -4.8e21 < x < 1.0499999999999999e-52Initial program 92.2%
Taylor expanded in x around 0 27.8%
+-commutative27.8%
Simplified89.6%
Taylor expanded in z around 0 27.8%
associate-/l*27.8%
rec-exp27.9%
rec-exp27.9%
tanh-def-a89.6%
Simplified89.6%
Final simplification89.4%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.4e-94) (not (<= t 3.45e-124))) (+ x (* (tanh (/ t y)) (* y z))) (- x (* (tanh (/ x y)) (* y z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.4e-94) || !(t <= 3.45e-124)) {
tmp = x + (tanh((t / y)) * (y * z));
} else {
tmp = x - (tanh((x / y)) * (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) :: tmp
if ((t <= (-1.4d-94)) .or. (.not. (t <= 3.45d-124))) then
tmp = x + (tanh((t / y)) * (y * z))
else
tmp = x - (tanh((x / y)) * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.4e-94) || !(t <= 3.45e-124)) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = x - (Math.tanh((x / y)) * (y * z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.4e-94) or not (t <= 3.45e-124): tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = x - (math.tanh((x / y)) * (y * z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.4e-94) || !(t <= 3.45e-124)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = Float64(x - Float64(tanh(Float64(x / y)) * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.4e-94) || ~((t <= 3.45e-124))) tmp = x + (tanh((t / y)) * (y * z)); else tmp = x - (tanh((x / y)) * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.4e-94], N[Not[LessEqual[t, 3.45e-124]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.4 \cdot 10^{-94} \lor \neg \left(t \leq 3.45 \cdot 10^{-124}\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x - \tanh \left(\frac{x}{y}\right) \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if t < -1.3999999999999999e-94 or 3.45e-124 < t Initial program 96.8%
Taylor expanded in x around 0 19.6%
associate-*r*19.4%
associate-/r*19.4%
div-sub19.4%
rec-exp19.5%
rec-exp19.5%
tanh-def-a89.9%
Simplified89.9%
if -1.3999999999999999e-94 < t < 3.45e-124Initial program 90.8%
+-commutative90.8%
associate-*l*96.0%
fma-define96.0%
Simplified96.0%
sub-neg96.0%
distribute-rgt-in96.0%
Applied egg-rr96.0%
Taylor expanded in t around 0 18.7%
mul-1-neg18.7%
unsub-neg18.7%
associate-/l*18.7%
associate-/l*18.7%
rec-exp18.7%
div-sub18.7%
Simplified85.7%
Final simplification88.7%
(FPCore (x y z t) :precision binary64 (if (<= y 3.2e+203) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.2e+203) {
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 <= 3.2d+203) 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 <= 3.2e+203) {
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 <= 3.2e+203: 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 <= 3.2e+203) 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 <= 3.2e+203) 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, 3.2e+203], 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 3.2 \cdot 10^{+203}:\\
\;\;\;\;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 < 3.1999999999999997e203Initial program 95.9%
Taylor expanded in x around 0 26.4%
associate-*r*26.2%
associate-/r*26.2%
div-sub26.2%
rec-exp26.2%
rec-exp26.2%
tanh-def-a83.6%
Simplified83.6%
if 3.1999999999999997e203 < y Initial program 84.4%
Taylor expanded in y around inf 95.2%
Final simplification84.4%
(FPCore (x y z t) :precision binary64 (if (<= y 1.05e+80) x (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.05e+80) {
tmp = x;
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.05e+80) tmp = x; else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.05e+80], x, N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.05 \cdot 10^{+80}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.05000000000000001e80Initial program 96.4%
Taylor expanded in x around inf 68.1%
if 1.05000000000000001e80 < y Initial program 88.2%
Taylor expanded in y around inf 86.4%
+-commutative86.4%
fma-define86.4%
Simplified86.4%
(FPCore (x y z t) :precision binary64 (if (<= y 1.72e+162) x (if (or (<= y 6.3e+258) (not (<= y 2.25e+290))) (* x (- 1.0 z)) (* t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.72e+162) {
tmp = x;
} else if ((y <= 6.3e+258) || !(y <= 2.25e+290)) {
tmp = x * (1.0 - z);
} else {
tmp = t * 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.72d+162) then
tmp = x
else if ((y <= 6.3d+258) .or. (.not. (y <= 2.25d+290))) then
tmp = x * (1.0d0 - z)
else
tmp = t * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.72e+162) {
tmp = x;
} else if ((y <= 6.3e+258) || !(y <= 2.25e+290)) {
tmp = x * (1.0 - z);
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.72e+162: tmp = x elif (y <= 6.3e+258) or not (y <= 2.25e+290): tmp = x * (1.0 - z) else: tmp = t * z return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.72e+162) tmp = x; elseif ((y <= 6.3e+258) || !(y <= 2.25e+290)) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.72e+162) tmp = x; elseif ((y <= 6.3e+258) || ~((y <= 2.25e+290))) tmp = x * (1.0 - z); else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.72e+162], x, If[Or[LessEqual[y, 6.3e+258], N[Not[LessEqual[y, 2.25e+290]], $MachinePrecision]], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(t * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.72 \cdot 10^{+162}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 6.3 \cdot 10^{+258} \lor \neg \left(y \leq 2.25 \cdot 10^{+290}\right):\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if y < 1.72e162Initial program 96.1%
Taylor expanded in x around inf 67.2%
if 1.72e162 < y < 6.30000000000000034e258 or 2.2499999999999998e290 < y Initial program 88.3%
Taylor expanded in y around inf 80.9%
Taylor expanded in x around inf 73.2%
mul-1-neg73.2%
unsub-neg73.2%
Simplified73.2%
if 6.30000000000000034e258 < y < 2.2499999999999998e290Initial program 75.0%
Taylor expanded in y around inf 52.4%
Taylor expanded in z around inf 77.4%
Taylor expanded in t around inf 53.1%
Final simplification67.6%
(FPCore (x y z t) :precision binary64 (if (<= y 8.5e+79) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.5e+79) {
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 <= 8.5d+79) 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 <= 8.5e+79) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8.5e+79: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8.5e+79) 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 <= 8.5e+79) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.5e+79], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{+79}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 8.4999999999999998e79Initial program 96.4%
Taylor expanded in x around inf 68.1%
if 8.4999999999999998e79 < y Initial program 88.2%
Taylor expanded in y around inf 86.4%
(FPCore (x y z t) :precision binary64 (if (<= y 2.85e+82) x (+ x (* t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.85e+82) {
tmp = x;
} else {
tmp = x + (t * z);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 2.85d+82) then
tmp = x
else
tmp = x + (t * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.85e+82) {
tmp = x;
} else {
tmp = x + (t * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.85e+82: tmp = x else: tmp = x + (t * z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.85e+82) tmp = x; else tmp = Float64(x + Float64(t * z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.85e+82) tmp = x; else tmp = x + (t * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.85e+82], x, N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.85 \cdot 10^{+82}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + t \cdot z\\
\end{array}
\end{array}
if y < 2.85000000000000008e82Initial program 96.4%
Taylor expanded in x around inf 68.1%
if 2.85000000000000008e82 < y Initial program 88.2%
Taylor expanded in y around inf 74.5%
Taylor expanded in t around inf 73.5%
*-commutative73.5%
Simplified73.5%
Final simplification69.0%
(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.0%
Taylor expanded in x around inf 65.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 2024085
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))