
(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 13 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 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 96.2%
+-commutative96.2%
*-commutative96.2%
associate-*l*98.8%
fma-def98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ x y))) (t_2 (+ x (* (- (tanh (/ t y)) t_1) (* z y))))) (if (<= t_2 2e+299) t_2 (fma z (- t (* y t_1)) x))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((x / y));
double t_2 = x + ((tanh((t / y)) - t_1) * (z * y));
double tmp;
if (t_2 <= 2e+299) {
tmp = t_2;
} else {
tmp = fma(z, (t - (y * t_1)), x);
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(x / y)) t_2 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - t_1) * Float64(z * y))) tmp = 0.0 if (t_2 <= 2e+299) tmp = t_2; else tmp = fma(z, Float64(t - Float64(y * t_1)), x); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 2e+299], t$95$2, N[(z * N[(t - N[(y * t$95$1), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{x}{y}\right)\\
t_2 := x + \left(\tanh \left(\frac{t}{y}\right) - t_1\right) \cdot \left(z \cdot y\right)\\
\mathbf{if}\;t_2 \leq 2 \cdot 10^{+299}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - y \cdot t_1, x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.0000000000000001e299Initial program 98.4%
if 2.0000000000000001e299 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 55.6%
+-commutative55.6%
*-commutative55.6%
associate-*l*84.9%
fma-def84.9%
Simplified84.9%
Taylor expanded in t around 0 77.5%
Taylor expanded in t around -inf 61.6%
mul-1-neg61.6%
unsub-neg61.6%
associate-/r*61.6%
rec-exp61.6%
div-sub61.6%
Simplified92.6%
Final simplification98.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -5400000000.0) (not (<= t 1.85e+18))) (+ x (* z (* y (tanh (/ t y))))) (fma z (- t (* y (tanh (/ x y)))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -5400000000.0) || !(t <= 1.85e+18)) {
tmp = x + (z * (y * tanh((t / y))));
} else {
tmp = fma(z, (t - (y * tanh((x / y)))), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((t <= -5400000000.0) || !(t <= 1.85e+18)) tmp = Float64(x + Float64(z * Float64(y * tanh(Float64(t / 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, -5400000000.0], N[Not[LessEqual[t, 1.85e+18]], $MachinePrecision]], N[(x + N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $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 -5400000000 \lor \neg \left(t \leq 1.85 \cdot 10^{+18}\right):\\
\;\;\;\;x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right)\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.4e9 or 1.85e18 < t Initial program 97.0%
Taylor expanded in x around 0 10.1%
associate-/r*10.1%
div-sub10.1%
rec-exp10.1%
rec-exp10.1%
tanh-def-a85.2%
Simplified85.2%
add-log-exp55.7%
associate-*r*55.7%
exp-prod52.5%
*-commutative52.5%
exp-prod43.5%
Applied egg-rr43.5%
log-pow43.5%
log-pow45.7%
rem-log-exp83.8%
Simplified83.8%
Taylor expanded in t around inf 10.1%
associate-*r*10.0%
associate-*r/10.0%
rec-exp10.0%
rec-exp10.0%
tanh-def-a83.8%
*-commutative83.8%
associate-*l*86.0%
Simplified86.0%
if -5.4e9 < t < 1.85e18Initial program 95.5%
+-commutative95.5%
*-commutative95.5%
associate-*l*97.8%
fma-def97.8%
Simplified97.8%
Taylor expanded in t around 0 89.6%
Taylor expanded in t around -inf 31.2%
mul-1-neg31.2%
unsub-neg31.2%
associate-/r*31.2%
rec-exp31.2%
div-sub31.2%
Simplified91.9%
Final simplification89.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))) (t_2 (+ x (* z (* y t_1)))))
(if (<= y 2650000000.0)
t_2
(if (<= y 1.82e+170)
(+ x (* (* z y) (- t_1 (/ x y))))
(if (<= y 7.5e+193) t_2 (+ x (* z (- t x))))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double t_2 = x + (z * (y * t_1));
double tmp;
if (y <= 2650000000.0) {
tmp = t_2;
} else if (y <= 1.82e+170) {
tmp = x + ((z * y) * (t_1 - (x / y)));
} else if (y <= 7.5e+193) {
tmp = t_2;
} 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = tanh((t / y))
t_2 = x + (z * (y * t_1))
if (y <= 2650000000.0d0) then
tmp = t_2
else if (y <= 1.82d+170) then
tmp = x + ((z * y) * (t_1 - (x / y)))
else if (y <= 7.5d+193) then
tmp = t_2
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 t_1 = Math.tanh((t / y));
double t_2 = x + (z * (y * t_1));
double tmp;
if (y <= 2650000000.0) {
tmp = t_2;
} else if (y <= 1.82e+170) {
tmp = x + ((z * y) * (t_1 - (x / y)));
} else if (y <= 7.5e+193) {
tmp = t_2;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) t_2 = x + (z * (y * t_1)) tmp = 0 if y <= 2650000000.0: tmp = t_2 elif y <= 1.82e+170: tmp = x + ((z * y) * (t_1 - (x / y))) elif y <= 7.5e+193: tmp = t_2 else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) t_2 = Float64(x + Float64(z * Float64(y * t_1))) tmp = 0.0 if (y <= 2650000000.0) tmp = t_2; elseif (y <= 1.82e+170) tmp = Float64(x + Float64(Float64(z * y) * Float64(t_1 - Float64(x / y)))); elseif (y <= 7.5e+193) tmp = t_2; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); t_2 = x + (z * (y * t_1)); tmp = 0.0; if (y <= 2650000000.0) tmp = t_2; elseif (y <= 1.82e+170) tmp = x + ((z * y) * (t_1 - (x / y))); elseif (y <= 7.5e+193) tmp = t_2; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(z * N[(y * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 2650000000.0], t$95$2, If[LessEqual[y, 1.82e+170], N[(x + N[(N[(z * y), $MachinePrecision] * N[(t$95$1 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e+193], t$95$2, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
t_2 := x + z \cdot \left(y \cdot t_1\right)\\
\mathbf{if}\;y \leq 2650000000:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 1.82 \cdot 10^{+170}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \left(t_1 - \frac{x}{y}\right)\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+193}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.65e9 or 1.82e170 < y < 7.5000000000000008e193Initial program 97.5%
Taylor expanded in x around 0 22.1%
associate-/r*22.1%
div-sub22.1%
rec-exp22.1%
rec-exp22.1%
tanh-def-a82.6%
Simplified82.6%
add-log-exp60.7%
associate-*r*60.7%
exp-prod57.5%
*-commutative57.5%
exp-prod42.7%
Applied egg-rr42.7%
log-pow42.6%
log-pow43.6%
rem-log-exp82.6%
Simplified82.6%
Taylor expanded in t around inf 22.1%
associate-*r*21.9%
associate-*r/21.9%
rec-exp22.0%
rec-exp22.0%
tanh-def-a82.6%
*-commutative82.6%
associate-*l*84.1%
Simplified84.1%
if 2.65e9 < y < 1.82e170Initial program 95.0%
Taylor expanded in x around 0 83.1%
if 7.5000000000000008e193 < y Initial program 88.1%
Taylor expanded in y around inf 93.0%
Final simplification84.8%
(FPCore (x y z t) :precision binary64 (if (or (<= t -15600000000000.0) (not (<= t 2.8e-32))) (+ x (* z (* y (tanh (/ t y))))) (+ x (* (* z y) (- (/ t y) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -15600000000000.0) || !(t <= 2.8e-32)) {
tmp = x + (z * (y * tanh((t / y))));
} else {
tmp = x + ((z * y) * ((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 <= (-15600000000000.0d0)) .or. (.not. (t <= 2.8d-32))) then
tmp = x + (z * (y * tanh((t / y))))
else
tmp = x + ((z * y) * ((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 <= -15600000000000.0) || !(t <= 2.8e-32)) {
tmp = x + (z * (y * Math.tanh((t / y))));
} else {
tmp = x + ((z * y) * ((t / y) - Math.tanh((x / y))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -15600000000000.0) or not (t <= 2.8e-32): tmp = x + (z * (y * math.tanh((t / y)))) else: tmp = x + ((z * y) * ((t / y) - math.tanh((x / y)))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -15600000000000.0) || !(t <= 2.8e-32)) tmp = Float64(x + Float64(z * Float64(y * tanh(Float64(t / y))))); else tmp = Float64(x + Float64(Float64(z * y) * Float64(Float64(t / y) - tanh(Float64(x / y))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -15600000000000.0) || ~((t <= 2.8e-32))) tmp = x + (z * (y * tanh((t / y)))); else tmp = x + ((z * y) * ((t / y) - tanh((x / y)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -15600000000000.0], N[Not[LessEqual[t, 2.8e-32]], $MachinePrecision]], N[(x + N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(z * y), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -15600000000000 \lor \neg \left(t \leq 2.8 \cdot 10^{-32}\right):\\
\;\;\;\;x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -1.56e13 or 2.7999999999999999e-32 < t Initial program 96.0%
Taylor expanded in x around 0 10.4%
associate-/r*10.4%
div-sub10.4%
rec-exp10.4%
rec-exp10.4%
tanh-def-a83.1%
Simplified83.1%
add-log-exp53.9%
associate-*r*53.9%
exp-prod51.1%
*-commutative51.1%
exp-prod41.9%
Applied egg-rr41.9%
log-pow41.9%
log-pow43.8%
rem-log-exp82.5%
Simplified82.5%
Taylor expanded in t around inf 10.4%
associate-*r*10.2%
associate-*r/10.2%
rec-exp10.2%
rec-exp10.2%
tanh-def-a82.5%
*-commutative82.5%
associate-*l*84.5%
Simplified84.5%
if -1.56e13 < t < 2.7999999999999999e-32Initial program 96.5%
Taylor expanded in t around 0 91.9%
Final simplification87.8%
(FPCore (x y z t) :precision binary64 (if (<= y 1.1e+114) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.1e+114) {
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 <= 1.1d+114) 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 <= 1.1e+114) {
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 <= 1.1e+114: 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 <= 1.1e+114) 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 <= 1.1e+114) 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, 1.1e+114], 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 1.1 \cdot 10^{+114}:\\
\;\;\;\;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 < 1.1e114Initial program 98.2%
Taylor expanded in x around 0 23.8%
associate-/r*23.8%
div-sub23.8%
rec-exp23.8%
rec-exp23.8%
tanh-def-a82.1%
Simplified82.1%
if 1.1e114 < y Initial program 85.5%
Taylor expanded in y around inf 93.3%
Final simplification83.8%
(FPCore (x y z t) :precision binary64 (if (<= y 2.7e+115) (+ x (* z (* y (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.7e+115) {
tmp = x + (z * (y * 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 <= 2.7d+115) then
tmp = x + (z * (y * 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 <= 2.7e+115) {
tmp = x + (z * (y * Math.tanh((t / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.7e+115: tmp = x + (z * (y * math.tanh((t / y)))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.7e+115) tmp = Float64(x + Float64(z * Float64(y * 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 <= 2.7e+115) tmp = x + (z * (y * tanh((t / y)))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.7e+115], N[(x + N[(z * N[(y * 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 2.7 \cdot 10^{+115}:\\
\;\;\;\;x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.70000000000000004e115Initial program 98.2%
Taylor expanded in x around 0 23.8%
associate-/r*23.8%
div-sub23.8%
rec-exp23.8%
rec-exp23.8%
tanh-def-a82.1%
Simplified82.1%
add-log-exp59.4%
associate-*r*59.4%
exp-prod56.1%
*-commutative56.1%
exp-prod43.6%
Applied egg-rr43.6%
log-pow43.5%
log-pow44.3%
rem-log-exp82.0%
Simplified82.0%
Taylor expanded in t around inf 23.8%
associate-*r*23.7%
associate-*r/23.7%
rec-exp23.7%
rec-exp23.7%
tanh-def-a82.0%
*-commutative82.0%
associate-*l*82.5%
Simplified82.5%
if 2.70000000000000004e115 < y Initial program 85.5%
Taylor expanded in y around inf 93.3%
Final simplification84.2%
(FPCore (x y z t) :precision binary64 (if (<= y 2650000000.0) x (if (or (<= y 1.42e+135) (not (<= y 1.1e+182))) (* x (- 1.0 z)) (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2650000000.0) {
tmp = x;
} else if ((y <= 1.42e+135) || !(y <= 1.1e+182)) {
tmp = x * (1.0 - z);
} 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 <= 2650000000.0d0) then
tmp = x
else if ((y <= 1.42d+135) .or. (.not. (y <= 1.1d+182))) then
tmp = x * (1.0d0 - z)
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 <= 2650000000.0) {
tmp = x;
} else if ((y <= 1.42e+135) || !(y <= 1.1e+182)) {
tmp = x * (1.0 - z);
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2650000000.0: tmp = x elif (y <= 1.42e+135) or not (y <= 1.1e+182): tmp = x * (1.0 - z) else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2650000000.0) tmp = x; elseif ((y <= 1.42e+135) || !(y <= 1.1e+182)) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2650000000.0) tmp = x; elseif ((y <= 1.42e+135) || ~((y <= 1.1e+182))) tmp = x * (1.0 - z); else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2650000000.0], x, If[Or[LessEqual[y, 1.42e+135], N[Not[LessEqual[y, 1.1e+182]], $MachinePrecision]], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2650000000:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.42 \cdot 10^{+135} \lor \neg \left(y \leq 1.1 \cdot 10^{+182}\right):\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 2.65e9Initial program 98.4%
Taylor expanded in x around inf 67.7%
if 2.65e9 < y < 1.41999999999999998e135 or 1.09999999999999998e182 < y Initial program 90.8%
Taylor expanded in y around inf 75.1%
Taylor expanded in x around inf 58.9%
mul-1-neg58.9%
unsub-neg58.9%
Simplified58.9%
if 1.41999999999999998e135 < y < 1.09999999999999998e182Initial program 86.5%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around 0 72.3%
Final simplification65.7%
(FPCore (x y z t) :precision binary64 (if (<= y 3.2e+105) x (if (<= y 7.2e+220) (* z (- t x)) (* x (- 1.0 z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.2e+105) {
tmp = x;
} else if (y <= 7.2e+220) {
tmp = z * (t - 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 <= 3.2d+105) then
tmp = x
else if (y <= 7.2d+220) then
tmp = z * (t - 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 <= 3.2e+105) {
tmp = x;
} else if (y <= 7.2e+220) {
tmp = z * (t - x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.2e+105: tmp = x elif y <= 7.2e+220: tmp = z * (t - x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.2e+105) tmp = x; elseif (y <= 7.2e+220) tmp = Float64(z * Float64(t - 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 <= 3.2e+105) tmp = x; elseif (y <= 7.2e+220) tmp = z * (t - x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.2e+105], x, If[LessEqual[y, 7.2e+220], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{+105}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{+220}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 3.2e105Initial program 98.2%
Taylor expanded in x around inf 64.6%
if 3.2e105 < y < 7.20000000000000038e220Initial program 86.5%
Taylor expanded in y around inf 91.1%
Taylor expanded in z around inf 72.6%
if 7.20000000000000038e220 < y Initial program 85.8%
Taylor expanded in y around inf 91.6%
Taylor expanded in x around inf 72.5%
mul-1-neg72.5%
unsub-neg72.5%
Simplified72.5%
Final simplification65.9%
(FPCore (x y z t) :precision binary64 (if (<= y 1.48e-29) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.48e-29) {
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.48d-29) 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.48e-29) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.48e-29: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.48e-29) 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.48e-29) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.48e-29], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.48 \cdot 10^{-29}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.4800000000000001e-29Initial program 98.4%
Taylor expanded in x around inf 67.9%
if 1.4800000000000001e-29 < y Initial program 91.0%
Taylor expanded in y around inf 75.2%
Final simplification70.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.48e-29) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.48e-29) {
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.48d-29) 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.48e-29) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.48e-29: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.48e-29) 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.48e-29) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.48e-29], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.48 \cdot 10^{-29}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.4800000000000001e-29Initial program 98.4%
Taylor expanded in x around inf 67.9%
if 1.4800000000000001e-29 < y Initial program 91.0%
+-commutative91.0%
*-commutative91.0%
associate-*l*97.4%
fma-def97.4%
Simplified97.4%
Taylor expanded in x around 0 32.4%
associate-/r*32.4%
div-sub32.4%
rec-exp32.4%
rec-exp32.4%
tanh-def-a73.4%
Simplified73.4%
Taylor expanded in y around inf 64.2%
Final simplification66.8%
(FPCore (x y z t) :precision binary64 (if (<= z 5.4e+230) x (* z t)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 5.4e+230) {
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 (z <= 5.4d+230) 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 (z <= 5.4e+230) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 5.4e+230: tmp = x else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 5.4e+230) tmp = x; else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 5.4e+230) tmp = x; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 5.4e+230], x, N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5.4 \cdot 10^{+230}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if z < 5.40000000000000006e230Initial program 96.8%
Taylor expanded in x around inf 63.8%
if 5.40000000000000006e230 < z Initial program 88.6%
Taylor expanded in y around inf 83.2%
Taylor expanded in x around 0 65.8%
Final simplification64.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 96.2%
Taylor expanded in x around inf 60.1%
Final simplification60.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 2024020
(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))))))