
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
(FPCore (x y z t) :precision binary64 (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 95.4%
+-commutative95.4%
*-commutative95.4%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Final simplification98.5%
(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}
Initial program 95.4%
sub-neg95.4%
distribute-lft-in91.0%
Applied egg-rr91.0%
distribute-lft-out95.4%
sub-neg95.4%
associate-*l*97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x y z t) :precision binary64 (if (or (<= t -3.5e-91) (not (<= t 2.8e-71))) (+ x (* (tanh (/ t y)) (* z y))) (+ x (* (* z y) (- (/ t y) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.5e-91) || !(t <= 2.8e-71)) {
tmp = x + (tanh((t / y)) * (z * 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 <= (-3.5d-91)) .or. (.not. (t <= 2.8d-71))) then
tmp = x + (tanh((t / y)) * (z * 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 <= -3.5e-91) || !(t <= 2.8e-71)) {
tmp = x + (Math.tanh((t / y)) * (z * y));
} else {
tmp = x + ((z * y) * ((t / y) - Math.tanh((x / y))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -3.5e-91) or not (t <= 2.8e-71): tmp = x + (math.tanh((t / y)) * (z * 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 <= -3.5e-91) || !(t <= 2.8e-71)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * 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 <= -3.5e-91) || ~((t <= 2.8e-71))) tmp = x + (tanh((t / y)) * (z * 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, -3.5e-91], N[Not[LessEqual[t, 2.8e-71]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $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 -3.5 \cdot 10^{-91} \lor \neg \left(t \leq 2.8 \cdot 10^{-71}\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\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 < -3.4999999999999999e-91 or 2.8e-71 < t Initial program 96.4%
Taylor expanded in x around 0 11.9%
associate-/r*11.9%
rec-exp11.9%
div-sub11.9%
rec-exp11.9%
tanh-def-a87.3%
Simplified87.3%
if -3.4999999999999999e-91 < t < 2.8e-71Initial program 93.7%
Taylor expanded in t around 0 89.8%
Final simplification88.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 7.2e+21) (+ x (* t_1 (* z 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 <= 7.2e+21) {
tmp = x + (t_1 * (z * 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 <= 7.2d+21) then
tmp = x + (t_1 * (z * 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 <= 7.2e+21) {
tmp = x + (t_1 * (z * 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 <= 7.2e+21: tmp = x + (t_1 * (z * 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 <= 7.2e+21) tmp = Float64(x + Float64(t_1 * Float64(z * 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 <= 7.2e+21) tmp = x + (t_1 * (z * 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, 7.2e+21], N[(x + N[(t$95$1 * N[(z * y), $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 7.2 \cdot 10^{+21}:\\
\;\;\;\;x + t\_1 \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t\_1 - x\right)\\
\end{array}
\end{array}
if y < 7.2e21Initial program 96.7%
Taylor expanded in x around 0 22.8%
associate-/r*22.8%
rec-exp22.8%
div-sub22.8%
rec-exp22.8%
tanh-def-a80.6%
Simplified80.6%
if 7.2e21 < y Initial program 90.2%
Taylor expanded in x around 0 42.7%
+-commutative42.7%
Simplified82.7%
fma-udef82.7%
unsub-neg82.7%
Applied egg-rr82.7%
Final simplification81.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.6e+81) (+ 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.6e+81) {
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.6d+81) 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.6e+81) {
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.6e+81: 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.6e+81) 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.6e+81) 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.6e+81], 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.6 \cdot 10^{+81}:\\
\;\;\;\;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.6e81Initial program 96.4%
Taylor expanded in x around 0 22.4%
associate-/r*22.4%
rec-exp22.4%
div-sub22.4%
rec-exp22.4%
tanh-def-a80.0%
Simplified80.0%
if 1.6e81 < y Initial program 90.4%
Taylor expanded in y around inf 78.1%
Final simplification79.7%
(FPCore (x y z t)
:precision binary64
(if (<= y 1.65e-6)
x
(if (or (<= y 1.3e+216) (not (<= y 3e+258)))
(+ x (* z t))
(* x (- 1.0 z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.65e-6) {
tmp = x;
} else if ((y <= 1.3e+216) || !(y <= 3e+258)) {
tmp = x + (z * t);
} 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 <= 1.65d-6) then
tmp = x
else if ((y <= 1.3d+216) .or. (.not. (y <= 3d+258))) then
tmp = x + (z * t)
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 <= 1.65e-6) {
tmp = x;
} else if ((y <= 1.3e+216) || !(y <= 3e+258)) {
tmp = x + (z * t);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.65e-6: tmp = x elif (y <= 1.3e+216) or not (y <= 3e+258): tmp = x + (z * t) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.65e-6) tmp = x; elseif ((y <= 1.3e+216) || !(y <= 3e+258)) tmp = Float64(x + Float64(z * t)); 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 <= 1.65e-6) tmp = x; elseif ((y <= 1.3e+216) || ~((y <= 3e+258))) tmp = x + (z * t); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.65e-6], x, If[Or[LessEqual[y, 1.3e+216], N[Not[LessEqual[y, 3e+258]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.65 \cdot 10^{-6}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{+216} \lor \neg \left(y \leq 3 \cdot 10^{+258}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 1.65000000000000008e-6Initial program 96.6%
Taylor expanded in y around inf 54.9%
Taylor expanded in z around 0 70.5%
if 1.65000000000000008e-6 < y < 1.2999999999999999e216 or 3e258 < y Initial program 91.4%
Taylor expanded in x around 0 26.8%
associate-/r*26.8%
rec-exp26.8%
div-sub26.8%
rec-exp26.8%
tanh-def-a74.9%
Simplified74.9%
Taylor expanded in y around inf 61.5%
+-commutative61.5%
*-commutative61.5%
Simplified61.5%
if 1.2999999999999999e216 < y < 3e258Initial program 91.2%
Taylor expanded in y around inf 93.9%
Taylor expanded in x around inf 85.2%
mul-1-neg85.2%
unsub-neg85.2%
Simplified85.2%
Final simplification69.5%
(FPCore (x y z t) :precision binary64 (if (<= y 4.4e+78) x (if (<= y 2.1e+260) (* x (- 1.0 z)) (if (<= y 1.7e+304) (* z t) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.4e+78) {
tmp = x;
} else if (y <= 2.1e+260) {
tmp = x * (1.0 - z);
} else if (y <= 1.7e+304) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 4.4d+78) then
tmp = x
else if (y <= 2.1d+260) then
tmp = x * (1.0d0 - z)
else if (y <= 1.7d+304) then
tmp = z * t
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.4e+78) {
tmp = x;
} else if (y <= 2.1e+260) {
tmp = x * (1.0 - z);
} else if (y <= 1.7e+304) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 4.4e+78: tmp = x elif y <= 2.1e+260: tmp = x * (1.0 - z) elif y <= 1.7e+304: tmp = z * t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 4.4e+78) tmp = x; elseif (y <= 2.1e+260) tmp = Float64(x * Float64(1.0 - z)); elseif (y <= 1.7e+304) tmp = Float64(z * t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.4e+78) tmp = x; elseif (y <= 2.1e+260) tmp = x * (1.0 - z); elseif (y <= 1.7e+304) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.4e+78], x, If[LessEqual[y, 2.1e+260], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.7e+304], N[(z * t), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.4 \cdot 10^{+78}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+260}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+304}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < 4.40000000000000028e78 or 1.7000000000000001e304 < y Initial program 96.4%
Taylor expanded in y around inf 53.8%
Taylor expanded in z around 0 68.2%
if 4.40000000000000028e78 < y < 2.10000000000000012e260Initial program 94.2%
Taylor expanded in y around inf 78.9%
Taylor expanded in x around inf 57.2%
mul-1-neg57.2%
unsub-neg57.2%
Simplified57.2%
if 2.10000000000000012e260 < y < 1.7000000000000001e304Initial program 72.0%
Taylor expanded in y around inf 74.6%
Taylor expanded in x around 0 46.9%
*-commutative46.9%
Simplified46.9%
Final simplification66.2%
(FPCore (x y z t) :precision binary64 (if (<= y 7e+20) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7e+20) {
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 <= 7d+20) 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 <= 7e+20) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 7e+20: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 7e+20) 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 <= 7e+20) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 7e+20], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{+20}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 7e20Initial program 96.7%
Taylor expanded in y around inf 54.1%
Taylor expanded in z around 0 70.1%
if 7e20 < y Initial program 90.2%
Taylor expanded in y around inf 72.7%
Final simplification70.6%
(FPCore (x y z t) :precision binary64 (if (<= y 1.8e+252) x (* z t)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e+252) {
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.8d+252) 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.8e+252) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.8e+252: tmp = x else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.8e+252) 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.8e+252) tmp = x; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.8e+252], x, N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{+252}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 1.7999999999999999e252Initial program 96.1%
Taylor expanded in y around inf 57.1%
Taylor expanded in z around 0 65.4%
if 1.7999999999999999e252 < y Initial program 75.3%
Taylor expanded in y around inf 77.8%
Taylor expanded in x around 0 41.4%
*-commutative41.4%
Simplified41.4%
Final simplification64.7%
(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.4%
Taylor expanded in y around inf 57.7%
Taylor expanded in z around 0 64.3%
Final simplification64.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 2024027
(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))))))