
(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))) (* z y))))) (if (<= t_1 5e+302) t_1 (* z (- t x)))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y));
double tmp;
if (t_1 <= 5e+302) {
tmp = t_1;
} else {
tmp = 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) :: t_1
real(8) :: tmp
t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y))
if (t_1 <= 5d+302) then
tmp = t_1
else
tmp = z * (t - 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))) * (z * y));
double tmp;
if (t_1 <= 5e+302) {
tmp = t_1;
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (z * y)) tmp = 0 if t_1 <= 5e+302: tmp = t_1 else: tmp = z * (t - x) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(z * y))) tmp = 0.0 if (t_1 <= 5e+302) tmp = t_1; else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y)); tmp = 0.0; if (t_1 <= 5e+302) tmp = t_1; else tmp = z * (t - 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[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+302], t$95$1, N[(z * N[(t - 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(z \cdot y\right)\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+302}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5e302Initial program 97.5%
if 5e302 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 44.3%
Taylor expanded in y around inf 44.5%
Taylor expanded in x around 0 89.4%
Taylor expanded in z around -inf 94.9%
associate-*r*94.9%
mul-1-neg94.9%
mul-1-neg94.9%
unsub-neg94.9%
Simplified94.9%
Final simplification97.3%
(FPCore (x y z t) :precision binary64 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(z * N[(y * 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(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 93.6%
+-commutative93.6%
*-commutative93.6%
associate-*l*97.2%
fma-def97.2%
Simplified97.2%
Final simplification97.2%
(FPCore (x y z t) :precision binary64 (if (or (<= t -5.2e-18) (not (<= t 1.08e-13))) (+ x (* (tanh (/ t y)) (* z y))) (fma z (- t (* y (tanh (/ x y)))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -5.2e-18) || !(t <= 1.08e-13)) {
tmp = x + (tanh((t / y)) * (z * y));
} else {
tmp = fma(z, (t - (y * tanh((x / y)))), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((t <= -5.2e-18) || !(t <= 1.08e-13)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))); else tmp = fma(z, Float64(t - Float64(y * tanh(Float64(x / y)))), x); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -5.2e-18], N[Not[LessEqual[t, 1.08e-13]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - N[(y * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.2 \cdot 10^{-18} \lor \neg \left(t \leq 1.08 \cdot 10^{-13}\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - y \cdot \tanh \left(\frac{x}{y}\right), x\right)\\
\end{array}
\end{array}
if t < -5.2000000000000001e-18 or 1.0799999999999999e-13 < t Initial program 97.7%
Taylor expanded in x around 0 11.6%
associate-*r*11.5%
associate-/r*11.5%
div-sub11.5%
rec-exp11.6%
rec-exp11.6%
tanh-def-a89.8%
Simplified89.8%
if -5.2000000000000001e-18 < t < 1.0799999999999999e-13Initial program 89.7%
+-commutative89.7%
*-commutative89.7%
associate-*l*94.5%
fma-def94.6%
Simplified94.6%
Taylor expanded in t around 0 86.6%
Taylor expanded in t around -inf 31.9%
mul-1-neg31.9%
unsub-neg31.9%
associate-/r*31.9%
rec-exp31.9%
div-sub31.9%
Simplified90.2%
Final simplification90.0%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.85e-18) (not (<= t 1.08e-13))) (+ x (* (tanh (/ t y)) (* z y))) (+ x (* z (- t (* y (tanh (/ x y))))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.85e-18) || !(t <= 1.08e-13)) {
tmp = x + (tanh((t / y)) * (z * 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 <= (-1.85d-18)) .or. (.not. (t <= 1.08d-13))) then
tmp = x + (tanh((t / y)) * (z * 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 <= -1.85e-18) || !(t <= 1.08e-13)) {
tmp = x + (Math.tanh((t / y)) * (z * y));
} else {
tmp = x + (z * (t - (y * Math.tanh((x / y)))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.85e-18) or not (t <= 1.08e-13): tmp = x + (math.tanh((t / y)) * (z * y)) else: tmp = x + (z * (t - (y * math.tanh((x / y))))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.85e-18) || !(t <= 1.08e-13)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * 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 <= -1.85e-18) || ~((t <= 1.08e-13))) tmp = x + (tanh((t / y)) * (z * y)); else tmp = x + (z * (t - (y * tanh((x / y))))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.85e-18], N[Not[LessEqual[t, 1.08e-13]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $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 -1.85 \cdot 10^{-18} \lor \neg \left(t \leq 1.08 \cdot 10^{-13}\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - y \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -1.8500000000000002e-18 or 1.0799999999999999e-13 < t Initial program 97.7%
Taylor expanded in x around 0 11.6%
associate-*r*11.5%
associate-/r*11.5%
div-sub11.5%
rec-exp11.6%
rec-exp11.6%
tanh-def-a89.8%
Simplified89.8%
if -1.8500000000000002e-18 < t < 1.0799999999999999e-13Initial program 89.7%
+-commutative89.7%
*-commutative89.7%
associate-*l*94.5%
fma-def94.6%
Simplified94.6%
Taylor expanded in t around 0 86.6%
Taylor expanded in t around -inf 31.9%
mul-1-neg31.9%
unsub-neg31.9%
associate-/r*31.9%
rec-exp31.9%
div-sub31.9%
Simplified90.2%
fma-udef90.2%
Applied egg-rr90.2%
Final simplification90.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.15e+137) (+ x (* (tanh (/ t y)) (* z y))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.15e+137) {
tmp = x + (tanh((t / y)) * (z * 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 <= 1.15d+137) then
tmp = x + (tanh((t / y)) * (z * 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 <= 1.15e+137) {
tmp = x + (Math.tanh((t / y)) * (z * y));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.15e+137: tmp = x + (math.tanh((t / y)) * (z * y)) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.15e+137) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * 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 <= 1.15e+137) tmp = x + (tanh((t / y)) * (z * y)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.15e+137], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.15 \cdot 10^{+137}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.15e137Initial program 94.6%
Taylor expanded in x around 0 29.0%
associate-*r*28.9%
associate-/r*28.9%
div-sub28.9%
rec-exp29.0%
rec-exp29.0%
tanh-def-a81.9%
Simplified81.9%
if 1.15e137 < y Initial program 86.5%
Taylor expanded in y around inf 86.3%
Final simplification82.5%
(FPCore (x y z t)
:precision binary64
(if (<= y 3.2e+47)
x
(if (<= y 6.5e+114)
(* x (- 1.0 z))
(if (or (<= y 3.4e+250) (not (<= y 2.3e+271)))
(+ x (* z t))
(* z (- t x))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.2e+47) {
tmp = x;
} else if (y <= 6.5e+114) {
tmp = x * (1.0 - z);
} else if ((y <= 3.4e+250) || !(y <= 2.3e+271)) {
tmp = x + (z * t);
} else {
tmp = 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+47) then
tmp = x
else if (y <= 6.5d+114) then
tmp = x * (1.0d0 - z)
else if ((y <= 3.4d+250) .or. (.not. (y <= 2.3d+271))) then
tmp = x + (z * t)
else
tmp = 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+47) {
tmp = x;
} else if (y <= 6.5e+114) {
tmp = x * (1.0 - z);
} else if ((y <= 3.4e+250) || !(y <= 2.3e+271)) {
tmp = x + (z * t);
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.2e+47: tmp = x elif y <= 6.5e+114: tmp = x * (1.0 - z) elif (y <= 3.4e+250) or not (y <= 2.3e+271): tmp = x + (z * t) else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.2e+47) tmp = x; elseif (y <= 6.5e+114) tmp = Float64(x * Float64(1.0 - z)); elseif ((y <= 3.4e+250) || !(y <= 2.3e+271)) tmp = Float64(x + Float64(z * t)); else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.2e+47) tmp = x; elseif (y <= 6.5e+114) tmp = x * (1.0 - z); elseif ((y <= 3.4e+250) || ~((y <= 2.3e+271))) tmp = x + (z * t); else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.2e+47], x, If[LessEqual[y, 6.5e+114], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 3.4e+250], N[Not[LessEqual[y, 2.3e+271]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{+47}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+114}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+250} \lor \neg \left(y \leq 2.3 \cdot 10^{+271}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.2e47Initial program 95.4%
Taylor expanded in x around inf 68.5%
if 3.2e47 < y < 6.5000000000000001e114Initial program 89.8%
Taylor expanded in y around inf 74.3%
Taylor expanded in x around inf 73.2%
mul-1-neg73.2%
unsub-neg73.2%
Simplified73.2%
if 6.5000000000000001e114 < y < 3.39999999999999973e250 or 2.3000000000000001e271 < y Initial program 83.7%
Taylor expanded in x around 0 31.8%
associate-*r*31.4%
associate-/r*31.4%
div-sub31.4%
rec-exp31.4%
rec-exp31.4%
tanh-def-a73.0%
Simplified73.0%
Taylor expanded in y around inf 69.5%
+-commutative69.5%
*-commutative69.5%
Simplified69.5%
if 3.39999999999999973e250 < y < 2.3000000000000001e271Initial program 99.6%
Taylor expanded in y around inf 99.6%
Taylor expanded in x around 0 100.0%
Taylor expanded in z around -inf 87.8%
associate-*r*87.8%
mul-1-neg87.8%
mul-1-neg87.8%
unsub-neg87.8%
Simplified87.8%
Final simplification69.6%
(FPCore (x y z t) :precision binary64 (if (or (<= y 1.55e+147) (and (not (<= y 2.45e+232)) (<= y 6.5e+250))) x (* z t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 1.55e+147) || (!(y <= 2.45e+232) && (y <= 6.5e+250))) {
tmp = x;
} else {
tmp = 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.55d+147) .or. (.not. (y <= 2.45d+232)) .and. (y <= 6.5d+250)) then
tmp = x
else
tmp = 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.55e+147) || (!(y <= 2.45e+232) && (y <= 6.5e+250))) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= 1.55e+147) or (not (y <= 2.45e+232) and (y <= 6.5e+250)): tmp = x else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= 1.55e+147) || (!(y <= 2.45e+232) && (y <= 6.5e+250))) tmp = x; else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= 1.55e+147) || (~((y <= 2.45e+232)) && (y <= 6.5e+250))) tmp = x; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, 1.55e+147], And[N[Not[LessEqual[y, 2.45e+232]], $MachinePrecision], LessEqual[y, 6.5e+250]]], x, N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.55 \cdot 10^{+147} \lor \neg \left(y \leq 2.45 \cdot 10^{+232}\right) \land y \leq 6.5 \cdot 10^{+250}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 1.55e147 or 2.45e232 < y < 6.5000000000000004e250Initial program 94.4%
Taylor expanded in x around inf 65.4%
if 1.55e147 < y < 2.45e232 or 6.5000000000000004e250 < y Initial program 87.1%
+-commutative87.1%
*-commutative87.1%
associate-*l*93.7%
fma-def93.7%
Simplified93.7%
Taylor expanded in t around 0 80.3%
Taylor expanded in t around -inf 65.3%
mul-1-neg65.3%
unsub-neg65.3%
associate-/r*65.3%
rec-exp65.3%
div-sub65.3%
Simplified86.5%
Taylor expanded in t around inf 55.4%
*-commutative55.4%
Simplified55.4%
Final simplification64.3%
(FPCore (x y z t) :precision binary64 (if (<= y 2.5e+48) x (if (<= y 6.1e+114) (* x (- 1.0 z)) (+ x (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.5e+48) {
tmp = x;
} else if (y <= 6.1e+114) {
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 <= 2.5d+48) then
tmp = x
else if (y <= 6.1d+114) 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 <= 2.5e+48) {
tmp = x;
} else if (y <= 6.1e+114) {
tmp = x * (1.0 - z);
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.5e+48: tmp = x elif y <= 6.1e+114: tmp = x * (1.0 - z) else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.5e+48) tmp = x; elseif (y <= 6.1e+114) 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 <= 2.5e+48) tmp = x; elseif (y <= 6.1e+114) tmp = x * (1.0 - z); else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.5e+48], x, If[LessEqual[y, 6.1e+114], 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 2.5 \cdot 10^{+48}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 6.1 \cdot 10^{+114}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 2.49999999999999987e48Initial program 95.4%
Taylor expanded in x around inf 68.5%
if 2.49999999999999987e48 < y < 6.1000000000000001e114Initial program 89.8%
Taylor expanded in y around inf 74.3%
Taylor expanded in x around inf 73.2%
mul-1-neg73.2%
unsub-neg73.2%
Simplified73.2%
if 6.1000000000000001e114 < y Initial program 86.7%
Taylor expanded in x around 0 27.8%
associate-*r*27.4%
associate-/r*27.4%
div-sub27.4%
rec-exp27.4%
rec-exp27.4%
tanh-def-a73.3%
Simplified73.3%
Taylor expanded in y around inf 68.2%
+-commutative68.2%
*-commutative68.2%
Simplified68.2%
Final simplification68.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -7e+220) (not (<= z 6e+185))) (- (* z x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -7e+220) || !(z <= 6e+185)) {
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 <= (-7d+220)) .or. (.not. (z <= 6d+185))) 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 <= -7e+220) || !(z <= 6e+185)) {
tmp = -(z * x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -7e+220) or not (z <= 6e+185): tmp = -(z * x) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -7e+220) || !(z <= 6e+185)) tmp = Float64(-Float64(z * x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -7e+220) || ~((z <= 6e+185))) tmp = -(z * x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -7e+220], N[Not[LessEqual[z, 6e+185]], $MachinePrecision]], (-N[(z * x), $MachinePrecision]), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7 \cdot 10^{+220} \lor \neg \left(z \leq 6 \cdot 10^{+185}\right):\\
\;\;\;\;-z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.99999999999999972e220 or 5.99999999999999988e185 < z Initial program 79.9%
Taylor expanded in y around inf 42.8%
Taylor expanded in x around inf 43.5%
mul-1-neg43.5%
unsub-neg43.5%
Simplified43.5%
Taylor expanded in z around inf 43.5%
mul-1-neg43.5%
distribute-lft-neg-out43.5%
*-commutative43.5%
Simplified43.5%
if -6.99999999999999972e220 < z < 5.99999999999999988e185Initial program 96.3%
Taylor expanded in x around inf 69.8%
Final simplification65.4%
(FPCore (x y z t) :precision binary64 (if (<= y 2.4e+46) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.4e+46) {
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 <= 2.4d+46) 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 <= 2.4e+46) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.4e+46: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.4e+46) 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 <= 2.4e+46) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.4e+46], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4 \cdot 10^{+46}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.40000000000000008e46Initial program 95.4%
Taylor expanded in x around inf 68.5%
if 2.40000000000000008e46 < y Initial program 87.6%
Taylor expanded in y around inf 84.3%
Final simplification72.2%
(FPCore (x y z t) :precision binary64 (if (<= y 5.6e+47) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.6e+47) {
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 <= 5.6d+47) 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 <= 5.6e+47) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 5.6e+47: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 5.6e+47) 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 <= 5.6e+47) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 5.6e+47], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.6 \cdot 10^{+47}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 5.59999999999999976e47Initial program 95.4%
Taylor expanded in x around inf 68.5%
if 5.59999999999999976e47 < y Initial program 87.6%
Taylor expanded in y around inf 71.9%
Taylor expanded in x around inf 52.6%
mul-1-neg52.6%
unsub-neg52.6%
Simplified52.6%
Final simplification64.8%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 93.6%
Taylor expanded in x around inf 60.0%
Final simplification60.0%
(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 2024026
(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))))))