
(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}
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 1.2e+125)
(+ x (* y (* z (- t_1 (tanh (/ x y))))))
(+ x (* z (- (* y t_1) x))))))y = abs(y);
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 1.2e+125) {
tmp = x + (y * (z * (t_1 - tanh((x / y)))));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 1.2d+125) then
tmp = x + (y * (z * (t_1 - tanh((x / y)))))
else
tmp = x + (z * ((y * t_1) - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 1.2e+125) {
tmp = x + (y * (z * (t_1 - Math.tanh((x / y)))));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 1.2e+125: tmp = x + (y * (z * (t_1 - math.tanh((x / y))))) else: tmp = x + (z * ((y * t_1) - x)) return tmp
y = abs(y) function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 1.2e+125) tmp = Float64(x + Float64(y * Float64(z * Float64(t_1 - tanh(Float64(x / y)))))); else tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 1.2e+125) tmp = x + (y * (z * (t_1 - tanh((x / y))))); else tmp = x + (z * ((y * t_1) - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 1.2e+125], N[(x + N[(y * N[(z * N[(t$95$1 - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 1.2 \cdot 10^{+125}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(t_1 - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 1.2e125Initial program 95.9%
associate-*l*98.1%
Simplified98.1%
if 1.2e125 < y Initial program 90.1%
associate-*l*90.2%
Simplified90.2%
Taylor expanded in x around 0 66.9%
mul-1-neg66.9%
unsub-neg66.9%
Simplified79.8%
Taylor expanded in z around 0 66.9%
*-commutative66.9%
Simplified100.0%
Final simplification98.4%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
y = abs(y);
double code(double x, double y, double z, double t) {
return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
y = abs(y) function code(x, y, z, t) return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
NOTE: y should be positive before calling this function 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}
y = |y|\\
\\
\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.0%
+-commutative95.0%
*-commutative95.0%
associate-*l*98.1%
fma-def98.1%
Simplified98.1%
Final simplification98.1%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (or (<= t -3.7e-37) (not (<= t 5.5e-42))) (fma z (* y (tanh (/ t y))) x) (fma z (- t (* y (tanh (/ x y)))) x)))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.7e-37) || !(t <= 5.5e-42)) {
tmp = fma(z, (y * tanh((t / y))), x);
} else {
tmp = fma(z, (t - (y * tanh((x / y)))), x);
}
return tmp;
}
y = abs(y) function code(x, y, z, t) tmp = 0.0 if ((t <= -3.7e-37) || !(t <= 5.5e-42)) tmp = fma(z, Float64(y * tanh(Float64(t / y))), x); else tmp = fma(z, Float64(t - Float64(y * tanh(Float64(x / y)))), x); end return tmp end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[Or[LessEqual[t, -3.7e-37], N[Not[LessEqual[t, 5.5e-42]], $MachinePrecision]], N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(t - N[(y * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.7 \cdot 10^{-37} \lor \neg \left(t \leq 5.5 \cdot 10^{-42}\right):\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot \tanh \left(\frac{t}{y}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - y \cdot \tanh \left(\frac{x}{y}\right), x\right)\\
\end{array}
\end{array}
if t < -3.7e-37 or 5.5e-42 < t Initial program 96.1%
+-commutative96.1%
*-commutative96.1%
associate-*l*99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in x around 0 8.6%
associate-/r*8.6%
div-sub8.6%
rec-exp8.6%
rec-exp8.6%
tanh-def-a86.2%
Simplified86.2%
if -3.7e-37 < t < 5.5e-42Initial program 93.7%
+-commutative93.7%
*-commutative93.7%
associate-*l*96.4%
fma-def96.4%
Simplified96.4%
Taylor expanded in t around 0 90.4%
Taylor expanded in t around -inf 36.7%
+-commutative36.7%
mul-1-neg36.7%
unsub-neg36.7%
associate-/r*36.7%
Simplified91.4%
Final simplification88.4%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (or (<= t -2.6e-52) (not (<= t 1.15e-42))) (fma z (* y (tanh (/ t y))) x) (+ x (* z (* y (- (/ t y) (tanh (/ x y))))))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.6e-52) || !(t <= 1.15e-42)) {
tmp = fma(z, (y * tanh((t / y))), x);
} else {
tmp = x + (z * (y * ((t / y) - tanh((x / y)))));
}
return tmp;
}
y = abs(y) function code(x, y, z, t) tmp = 0.0 if ((t <= -2.6e-52) || !(t <= 1.15e-42)) tmp = fma(z, Float64(y * tanh(Float64(t / y))), x); else tmp = Float64(x + Float64(z * Float64(y * Float64(Float64(t / y) - tanh(Float64(x / y)))))); end return tmp end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[Or[LessEqual[t, -2.6e-52], N[Not[LessEqual[t, 1.15e-42]], $MachinePrecision]], N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(z * N[(y * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.6 \cdot 10^{-52} \lor \neg \left(t \leq 1.15 \cdot 10^{-42}\right):\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot \tanh \left(\frac{t}{y}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\end{array}
\end{array}
if t < -2.5999999999999999e-52 or 1.15000000000000002e-42 < t Initial program 96.2%
+-commutative96.2%
*-commutative96.2%
associate-*l*99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in x around 0 9.8%
associate-/r*9.8%
div-sub9.8%
rec-exp9.8%
rec-exp9.8%
tanh-def-a86.6%
Simplified86.6%
if -2.5999999999999999e-52 < t < 1.15000000000000002e-42Initial program 93.4%
+-commutative93.4%
*-commutative93.4%
associate-*l*96.2%
fma-def96.3%
Simplified96.3%
Taylor expanded in t around 0 90.1%
fma-udef90.1%
Applied egg-rr90.1%
Final simplification88.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 1.15e+78) (+ x (* t_1 (* z y))) (+ x (* z (- (* y t_1) x))))))
y = abs(y);
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 1.15e+78) {
tmp = x + (t_1 * (z * y));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 1.15d+78) then
tmp = x + (t_1 * (z * y))
else
tmp = x + (z * ((y * t_1) - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 1.15e+78) {
tmp = x + (t_1 * (z * y));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 1.15e+78: tmp = x + (t_1 * (z * y)) else: tmp = x + (z * ((y * t_1) - x)) return tmp
y = abs(y) function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 1.15e+78) 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
y = abs(y) function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 1.15e+78) tmp = x + (t_1 * (z * y)); else tmp = x + (z * ((y * t_1) - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 1.15e+78], 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}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 1.15 \cdot 10^{+78}:\\
\;\;\;\;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 < 1.1500000000000001e78Initial program 95.6%
associate-*l*98.0%
Simplified98.0%
Taylor expanded in x around 0 20.8%
*-commutative20.8%
associate-/r*20.8%
div-sub20.8%
rec-exp20.8%
rec-exp20.8%
Simplified80.4%
if 1.1500000000000001e78 < y Initial program 92.7%
associate-*l*92.8%
Simplified92.8%
Taylor expanded in x around 0 60.9%
mul-1-neg60.9%
unsub-neg60.9%
Simplified78.2%
Taylor expanded in z around 0 60.9%
*-commutative60.9%
Simplified93.0%
Final simplification83.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 3.8e+166) (+ x (* (tanh (/ t y)) (* z y))) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.8e+166) {
tmp = x + (tanh((t / y)) * (z * y));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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.8d+166) then
tmp = x + (tanh((t / y)) * (z * y))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.8e+166) {
tmp = x + (Math.tanh((t / y)) * (z * y));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 3.8e+166: tmp = x + (math.tanh((t / y)) * (z * y)) else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 3.8e+166) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.8e+166) tmp = x + (tanh((t / y)) * (z * y)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 3.8e+166], 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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.8 \cdot 10^{+166}:\\
\;\;\;\;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 < 3.80000000000000007e166Initial program 96.1%
associate-*l*97.8%
Simplified97.8%
Taylor expanded in x around 0 22.8%
*-commutative22.8%
associate-/r*22.8%
div-sub22.8%
rec-exp22.8%
rec-exp22.8%
Simplified79.7%
if 3.80000000000000007e166 < y Initial program 87.2%
associate-*l*90.2%
Simplified90.2%
Taylor expanded in y around inf 95.9%
Final simplification81.6%
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (* z x))))
(if (<= y 6e+38)
x
(if (<= y 1.55e+87)
t_1
(if (<= y 8.3e+96)
x
(if (or (<= y 1.35e+121) (not (<= y 8e+236))) (+ x (* z t)) t_1))))))y = abs(y);
double code(double x, double y, double z, double t) {
double t_1 = x - (z * x);
double tmp;
if (y <= 6e+38) {
tmp = x;
} else if (y <= 1.55e+87) {
tmp = t_1;
} else if (y <= 8.3e+96) {
tmp = x;
} else if ((y <= 1.35e+121) || !(y <= 8e+236)) {
tmp = x + (z * t);
} else {
tmp = t_1;
}
return tmp;
}
NOTE: y should be positive before calling this function
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 - (z * x)
if (y <= 6d+38) then
tmp = x
else if (y <= 1.55d+87) then
tmp = t_1
else if (y <= 8.3d+96) then
tmp = x
else if ((y <= 1.35d+121) .or. (.not. (y <= 8d+236))) then
tmp = x + (z * t)
else
tmp = t_1
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double t_1 = x - (z * x);
double tmp;
if (y <= 6e+38) {
tmp = x;
} else if (y <= 1.55e+87) {
tmp = t_1;
} else if (y <= 8.3e+96) {
tmp = x;
} else if ((y <= 1.35e+121) || !(y <= 8e+236)) {
tmp = x + (z * t);
} else {
tmp = t_1;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): t_1 = x - (z * x) tmp = 0 if y <= 6e+38: tmp = x elif y <= 1.55e+87: tmp = t_1 elif y <= 8.3e+96: tmp = x elif (y <= 1.35e+121) or not (y <= 8e+236): tmp = x + (z * t) else: tmp = t_1 return tmp
y = abs(y) function code(x, y, z, t) t_1 = Float64(x - Float64(z * x)) tmp = 0.0 if (y <= 6e+38) tmp = x; elseif (y <= 1.55e+87) tmp = t_1; elseif (y <= 8.3e+96) tmp = x; elseif ((y <= 1.35e+121) || !(y <= 8e+236)) tmp = Float64(x + Float64(z * t)); else tmp = t_1; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) t_1 = x - (z * x); tmp = 0.0; if (y <= 6e+38) tmp = x; elseif (y <= 1.55e+87) tmp = t_1; elseif (y <= 8.3e+96) tmp = x; elseif ((y <= 1.35e+121) || ~((y <= 8e+236))) tmp = x + (z * t); else tmp = t_1; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 6e+38], x, If[LessEqual[y, 1.55e+87], t$95$1, If[LessEqual[y, 8.3e+96], x, If[Or[LessEqual[y, 1.35e+121], N[Not[LessEqual[y, 8e+236]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := x - z \cdot x\\
\mathbf{if}\;y \leq 6 \cdot 10^{+38}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+87}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 8.3 \cdot 10^{+96}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+121} \lor \neg \left(y \leq 8 \cdot 10^{+236}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < 6.0000000000000002e38 or 1.55e87 < y < 8.2999999999999997e96Initial program 96.0%
associate-*l*98.4%
Simplified98.4%
Taylor expanded in y around inf 47.8%
Taylor expanded in z around 0 61.9%
if 6.0000000000000002e38 < y < 1.55e87 or 1.3500000000000001e121 < y < 8.00000000000000043e236Initial program 94.8%
associate-*l*92.3%
Simplified92.3%
Taylor expanded in x around 0 51.6%
mul-1-neg51.6%
unsub-neg51.6%
Simplified83.3%
Taylor expanded in y around 0 60.3%
if 8.2999999999999997e96 < y < 1.3500000000000001e121 or 8.00000000000000043e236 < y Initial program 87.4%
associate-*l*91.5%
Simplified91.5%
Taylor expanded in x around 0 40.3%
*-commutative40.3%
associate-/r*40.3%
div-sub40.3%
rec-exp40.3%
rec-exp40.3%
Simplified62.4%
Taylor expanded in y around inf 65.4%
Final simplification62.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 3.4e+33) x (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.4e+33) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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.4d+33) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.4e+33) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 3.4e+33: tmp = x else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 3.4e+33) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.4e+33) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 3.4e+33], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{+33}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.3999999999999999e33Initial program 95.9%
associate-*l*98.4%
Simplified98.4%
Taylor expanded in y around inf 47.4%
Taylor expanded in z around 0 61.4%
if 3.3999999999999999e33 < y Initial program 92.6%
associate-*l*92.6%
Simplified92.6%
Taylor expanded in y around inf 82.2%
Final simplification66.7%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 4.5e+33) x (+ x (* z t))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.5e+33) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
NOTE: y should be positive before calling this function
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.5d+33) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.5e+33) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 4.5e+33: tmp = x else: tmp = x + (z * t) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 4.5e+33) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.5e+33) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 4.5e+33], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.5 \cdot 10^{+33}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 4.5e33Initial program 95.9%
associate-*l*98.4%
Simplified98.4%
Taylor expanded in y around inf 47.4%
Taylor expanded in z around 0 61.4%
if 4.5e33 < y Initial program 92.6%
associate-*l*92.6%
Simplified92.6%
Taylor expanded in x around 0 33.6%
*-commutative33.6%
associate-/r*33.6%
div-sub33.6%
rec-exp33.6%
rec-exp33.6%
Simplified69.8%
Taylor expanded in y around inf 59.8%
Final simplification61.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 x)
y = abs(y);
double code(double x, double y, double z, double t) {
return x;
}
NOTE: y should be positive before calling this function
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
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
return x;
}
y = abs(y) def code(x, y, z, t): return x
y = abs(y) function code(x, y, z, t) return x end
y = abs(y) function tmp = code(x, y, z, t) tmp = x; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := x
\begin{array}{l}
y = |y|\\
\\
x
\end{array}
Initial program 95.0%
associate-*l*96.9%
Simplified96.9%
Taylor expanded in y around inf 56.3%
Taylor expanded in z around 0 56.8%
Final simplification56.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 2023230
(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))))))