
(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 11 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 (+ x (* z (- (* y (tanh (/ t y))) (* y (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (z * ((y * tanh((t / y))) - (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 + (z * ((y * tanh((t / y))) - (y * tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (z * ((y * Math.tanh((t / y))) - (y * Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (z * ((y * math.tanh((t / y))) - (y * math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(z * Float64(Float64(y * tanh(Float64(t / y))) - Float64(y * tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (z * ((y * tanh((t / y))) - (y * tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(z * N[(N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(y * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right) - y \cdot \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Initial program 93.7%
sub-neg93.7%
distribute-lft-in88.4%
Applied egg-rr88.4%
Taylor expanded in z around 0 11.3%
+-commutative11.3%
mul-1-neg11.3%
Simplified98.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 5.8e+174)
(+ x (* (* z y) (- t_1 (tanh (/ x y)))))
(+ x (* z (- (* y t_1) x))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 5.8e+174) {
tmp = x + ((z * y) * (t_1 - tanh((x / y))));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= 5.8d+174) then
tmp = x + ((z * y) * (t_1 - tanh((x / y))))
else
tmp = x + (z * ((y * t_1) - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 5.8e+174) {
tmp = x + ((z * y) * (t_1 - Math.tanh((x / y))));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 5.8e+174: tmp = x + ((z * y) * (t_1 - math.tanh((x / y)))) else: tmp = x + (z * ((y * t_1) - x)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 5.8e+174) tmp = Float64(x + Float64(Float64(z * y) * Float64(t_1 - tanh(Float64(x / y))))); else tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 5.8e+174) tmp = x + ((z * y) * (t_1 - tanh((x / y)))); else tmp = x + (z * ((y * t_1) - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 5.8e+174], N[(x + N[(N[(z * y), $MachinePrecision] * N[(t$95$1 - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 5.8 \cdot 10^{+174}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \left(t\_1 - \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t\_1 - x\right)\\
\end{array}
\end{array}
if y < 5.7999999999999999e174Initial program 95.4%
if 5.7999999999999999e174 < y Initial program 77.6%
sub-neg77.6%
distribute-lft-in56.5%
Applied egg-rr56.5%
Taylor expanded in z around 0 35.6%
+-commutative35.6%
mul-1-neg35.6%
Simplified85.9%
Taylor expanded in x around 0 72.0%
mul-1-neg72.0%
+-commutative72.0%
associate-/l*72.0%
rec-exp72.0%
rec-exp72.0%
tanh-def-a90.2%
unsub-neg90.2%
Simplified90.2%
Final simplification94.9%
(FPCore (x y z t) :precision binary64 (if (or (<= t -235000000.0) (not (<= t 4000000000000.0))) (fma y (* z (tanh (/ t y))) x) (+ x (* z (- t (* y (tanh (/ x y))))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -235000000.0) || !(t <= 4000000000000.0)) {
tmp = fma(y, (z * tanh((t / y))), x);
} else {
tmp = x + (z * (t - (y * tanh((x / y)))));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((t <= -235000000.0) || !(t <= 4000000000000.0)) tmp = fma(y, Float64(z * tanh(Float64(t / y))), x); else tmp = Float64(x + Float64(z * Float64(t - Float64(y * tanh(Float64(x / y)))))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -235000000.0], N[Not[LessEqual[t, 4000000000000.0]], $MachinePrecision]], N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + x), $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 -235000000 \lor \neg \left(t \leq 4000000000000\right):\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \tanh \left(\frac{t}{y}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - y \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -2.35e8 or 4e12 < t Initial program 96.6%
+-commutative96.6%
associate-*l*99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in x around 0 10.2%
associate-/r*10.2%
div-sub10.2%
rec-exp10.2%
rec-exp10.2%
tanh-def-a84.9%
Simplified84.9%
if -2.35e8 < t < 4e12Initial program 91.2%
sub-neg91.2%
distribute-lft-in88.0%
Applied egg-rr88.0%
Taylor expanded in z around 0 16.8%
+-commutative16.8%
mul-1-neg16.8%
Simplified96.3%
Taylor expanded in t around 0 27.5%
associate-/l*27.5%
rec-exp27.5%
rec-exp27.5%
tanh-def-a88.7%
Simplified88.7%
Final simplification87.0%
(FPCore (x y z t) :precision binary64 (if (or (<= x -7.5e-80) (not (<= x 5.5e+39))) (- x (* (tanh (/ x y)) (* z y))) (+ x (* z (- (* y (tanh (/ t y))) x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -7.5e-80) || !(x <= 5.5e+39)) {
tmp = x - (tanh((x / y)) * (z * y));
} 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 <= (-7.5d-80)) .or. (.not. (x <= 5.5d+39))) then
tmp = x - (tanh((x / y)) * (z * y))
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 <= -7.5e-80) || !(x <= 5.5e+39)) {
tmp = x - (Math.tanh((x / y)) * (z * y));
} else {
tmp = x + (z * ((y * Math.tanh((t / y))) - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -7.5e-80) or not (x <= 5.5e+39): tmp = x - (math.tanh((x / y)) * (z * y)) else: tmp = x + (z * ((y * math.tanh((t / y))) - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -7.5e-80) || !(x <= 5.5e+39)) tmp = Float64(x - Float64(tanh(Float64(x / y)) * Float64(z * y))); 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 <= -7.5e-80) || ~((x <= 5.5e+39))) tmp = x - (tanh((x / y)) * (z * y)); else tmp = x + (z * ((y * tanh((t / y))) - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -7.5e-80], N[Not[LessEqual[x, 5.5e+39]], $MachinePrecision]], N[(x - N[(N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $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 -7.5 \cdot 10^{-80} \lor \neg \left(x \leq 5.5 \cdot 10^{+39}\right):\\
\;\;\;\;x - \tanh \left(\frac{x}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right) - x\right)\\
\end{array}
\end{array}
if x < -7.49999999999999999e-80 or 5.4999999999999997e39 < x Initial program 97.0%
sub-neg97.0%
distribute-lft-in91.0%
Applied egg-rr91.0%
Taylor expanded in t around 0 10.2%
mul-1-neg10.2%
associate-/l*10.2%
associate-/l*10.2%
rec-exp10.2%
rec-exp10.2%
tanh-def-a88.7%
associate-*l*87.3%
*-commutative87.3%
distribute-rgt-neg-in87.3%
Simplified87.3%
if -7.49999999999999999e-80 < x < 5.4999999999999997e39Initial program 90.0%
sub-neg90.0%
distribute-lft-in85.6%
Applied egg-rr85.6%
Taylor expanded in z around 0 14.2%
+-commutative14.2%
mul-1-neg14.2%
Simplified95.8%
Taylor expanded in x around 0 28.6%
mul-1-neg28.6%
+-commutative28.6%
associate-/l*28.6%
rec-exp28.6%
rec-exp28.6%
tanh-def-a86.1%
unsub-neg86.1%
Simplified86.1%
Final simplification86.7%
(FPCore (x y z t) :precision binary64 (if (or (<= t -2.8e-36) (not (<= t 15000000000000.0))) (+ 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 <= -2.8e-36) || !(t <= 15000000000000.0)) {
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 <= (-2.8d-36)) .or. (.not. (t <= 15000000000000.0d0))) 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 <= -2.8e-36) || !(t <= 15000000000000.0)) {
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 <= -2.8e-36) or not (t <= 15000000000000.0): 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 <= -2.8e-36) || !(t <= 15000000000000.0)) 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 <= -2.8e-36) || ~((t <= 15000000000000.0))) 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, -2.8e-36], N[Not[LessEqual[t, 15000000000000.0]], $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 -2.8 \cdot 10^{-36} \lor \neg \left(t \leq 15000000000000\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 < -2.8000000000000001e-36 or 1.5e13 < t Initial program 96.9%
Taylor expanded in x around 0 11.0%
associate-*r*10.9%
associate-/r*10.9%
div-sub10.9%
rec-exp10.9%
rec-exp10.9%
tanh-def-a83.0%
Simplified83.0%
if -2.8000000000000001e-36 < t < 1.5e13Initial program 90.5%
sub-neg90.5%
distribute-lft-in87.1%
Applied egg-rr87.1%
Taylor expanded in z around 0 16.5%
+-commutative16.5%
mul-1-neg16.5%
Simplified96.0%
Taylor expanded in t around 0 27.1%
associate-/l*27.1%
rec-exp27.1%
rec-exp27.1%
tanh-def-a90.1%
Simplified90.1%
Final simplification86.6%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.52e-71) (not (<= t 4.4e-49))) (+ x (* (tanh (/ t y)) (* z y))) (- x (* (tanh (/ x y)) (* z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.52e-71) || !(t <= 4.4e-49)) {
tmp = x + (tanh((t / y)) * (z * y));
} else {
tmp = x - (tanh((x / y)) * (z * 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.52d-71)) .or. (.not. (t <= 4.4d-49))) then
tmp = x + (tanh((t / y)) * (z * y))
else
tmp = x - (tanh((x / y)) * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.52e-71) || !(t <= 4.4e-49)) {
tmp = x + (Math.tanh((t / y)) * (z * y));
} else {
tmp = x - (Math.tanh((x / y)) * (z * y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.52e-71) or not (t <= 4.4e-49): tmp = x + (math.tanh((t / y)) * (z * y)) else: tmp = x - (math.tanh((x / y)) * (z * y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.52e-71) || !(t <= 4.4e-49)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))); else tmp = Float64(x - Float64(tanh(Float64(x / y)) * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.52e-71) || ~((t <= 4.4e-49))) tmp = x + (tanh((t / y)) * (z * y)); else tmp = x - (tanh((x / y)) * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.52e-71], N[Not[LessEqual[t, 4.4e-49]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.52 \cdot 10^{-71} \lor \neg \left(t \leq 4.4 \cdot 10^{-49}\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x - \tanh \left(\frac{x}{y}\right) \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if t < -1.52000000000000001e-71 or 4.3999999999999998e-49 < t Initial program 95.4%
Taylor expanded in x around 0 13.7%
associate-*r*13.6%
associate-/r*13.6%
div-sub13.6%
rec-exp13.6%
rec-exp13.6%
tanh-def-a82.2%
Simplified82.2%
if -1.52000000000000001e-71 < t < 4.3999999999999998e-49Initial program 91.3%
sub-neg91.3%
distribute-lft-in87.4%
Applied egg-rr87.4%
Taylor expanded in t around 0 17.5%
mul-1-neg17.5%
associate-/l*17.5%
associate-/l*17.5%
rec-exp17.5%
rec-exp17.5%
tanh-def-a87.1%
associate-*l*83.3%
*-commutative83.3%
distribute-rgt-neg-in83.3%
Simplified83.3%
Final simplification82.7%
(FPCore (x y z t) :precision binary64 (if (<= y 2.6e+107) (+ x (* (tanh (/ t y)) (* z y))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.6e+107) {
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 <= 2.6d+107) 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 <= 2.6e+107) {
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 <= 2.6e+107: 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 <= 2.6e+107) 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 <= 2.6e+107) 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, 2.6e+107], 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 2.6 \cdot 10^{+107}:\\
\;\;\;\;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 < 2.6000000000000001e107Initial program 95.5%
Taylor expanded in x around 0 22.0%
associate-*r*21.8%
associate-/r*21.8%
div-sub21.8%
rec-exp21.8%
rec-exp21.8%
tanh-def-a74.9%
Simplified74.9%
if 2.6000000000000001e107 < y Initial program 83.6%
Taylor expanded in y around inf 83.3%
Final simplification76.1%
(FPCore (x y z t) :precision binary64 (if (<= y 1.6e-32) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.6e-32) {
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.6d-32) 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.6e-32) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.6e-32: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.6e-32) 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.6e-32) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.6e-32], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{-32}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.6000000000000001e-32Initial program 95.3%
+-commutative95.3%
associate-*l*99.0%
fma-define99.0%
Simplified99.0%
Taylor expanded in y around 0 60.7%
if 1.6000000000000001e-32 < y Initial program 89.5%
Taylor expanded in y around inf 67.6%
(FPCore (x y z t) :precision binary64 (if (<= y 1.4e+46) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.4e+46) {
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.4d+46) 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.4e+46) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.4e+46: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.4e+46) 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.4e+46) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.4e+46], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{+46}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.40000000000000009e46Initial program 95.7%
+-commutative95.7%
associate-*l*99.1%
fma-define99.1%
Simplified99.1%
Taylor expanded in y around 0 58.4%
if 1.40000000000000009e46 < y Initial program 86.0%
Taylor expanded in t around 0 73.5%
Taylor expanded in y around 0 55.0%
*-commutative55.0%
Simplified55.0%
(FPCore (x y z t) :precision binary64 (if (<= y 2.7e+106) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.7e+106) {
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 <= 2.7d+106) 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 <= 2.7e+106) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.7e+106: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.7e+106) 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 <= 2.7e+106) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.7e+106], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.7 \cdot 10^{+106}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 2.70000000000000006e106Initial program 95.5%
+-commutative95.5%
associate-*l*99.1%
fma-define99.1%
Simplified99.1%
Taylor expanded in y around 0 57.5%
if 2.70000000000000006e106 < y Initial program 83.6%
+-commutative83.6%
associate-*l*91.2%
fma-define91.2%
Simplified91.2%
Taylor expanded in y around inf 74.5%
Taylor expanded in t around 0 56.5%
*-rgt-identity56.5%
mul-1-neg56.5%
distribute-rgt-neg-in56.5%
mul-1-neg56.5%
distribute-lft-in56.5%
mul-1-neg56.5%
unsub-neg56.5%
Simplified56.5%
(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.7%
+-commutative93.7%
associate-*l*97.9%
fma-define97.9%
Simplified97.9%
Taylor expanded in y around 0 53.8%
(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 2024139
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))