
(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}
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.1e+206) (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.1e+206) {
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / 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 <= 1.1d+206) then
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / 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 <= 1.1e+206) {
tmp = x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1.1e+206: tmp = x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y))))) else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.1e+206) tmp = Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / 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 <= 1.1e+206) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / 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, 1.1e+206], 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], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{+206}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.10000000000000001e206Initial program 95.2%
associate-*l*98.5%
Simplified98.5%
if 1.10000000000000001e206 < y Initial program 87.0%
+-commutative87.0%
*-commutative87.0%
associate-*l*93.6%
fma-def93.6%
Simplified93.6%
Taylor expanded in y around inf 100.0%
Final simplification98.6%
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 94.7%
+-commutative94.7%
*-commutative94.7%
associate-*l*98.6%
fma-def98.6%
Simplified98.6%
Final simplification98.6%
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 4e-231)
x
(if (<= y 850000000000.0)
(+ x (* t_1 (* z y)))
(fma z (- (* y t_1) x) x)))))y = abs(y);
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 4e-231) {
tmp = x;
} else if (y <= 850000000000.0) {
tmp = x + (t_1 * (z * y));
} else {
tmp = fma(z, ((y * t_1) - x), x);
}
return tmp;
}
y = abs(y) function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 4e-231) tmp = x; elseif (y <= 850000000000.0) tmp = Float64(x + Float64(t_1 * Float64(z * y))); else tmp = fma(z, Float64(Float64(y * t_1) - x), x); end return 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, 4e-231], x, If[LessEqual[y, 850000000000.0], N[(x + N[(t$95$1 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 4 \cdot 10^{-231}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 850000000000:\\
\;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot t_1 - x, x\right)\\
\end{array}
\end{array}
if y < 4e-231Initial program 93.5%
Taylor expanded in x around inf 63.0%
if 4e-231 < y < 8.5e11Initial program 100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in x around 0 28.6%
*-commutative28.6%
associate-*r*28.6%
associate-/r*28.6%
div-sub28.6%
rec-exp28.6%
rec-exp28.6%
Simplified88.2%
if 8.5e11 < y Initial program 93.3%
+-commutative93.3%
*-commutative93.3%
associate-*l*98.3%
fma-def98.3%
Simplified98.3%
Taylor expanded in x around 0 42.4%
+-commutative42.4%
mul-1-neg42.4%
unsub-neg42.4%
Simplified87.1%
Final simplification73.4%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (or (<= t -8e-222) (not (<= t 100.0))) (+ x (* (tanh (/ t y)) (* z y))) (+ x (* y (* z (- (/ t y) (tanh (/ x y))))))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -8e-222) || !(t <= 100.0)) {
tmp = x + (tanh((t / y)) * (z * y));
} else {
tmp = x + (y * (z * ((t / y) - tanh((x / y)))));
}
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 ((t <= (-8d-222)) .or. (.not. (t <= 100.0d0))) then
tmp = x + (tanh((t / y)) * (z * y))
else
tmp = x + (y * (z * ((t / y) - tanh((x / y)))))
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 ((t <= -8e-222) || !(t <= 100.0)) {
tmp = x + (Math.tanh((t / y)) * (z * y));
} else {
tmp = x + (y * (z * ((t / y) - Math.tanh((x / y)))));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if (t <= -8e-222) or not (t <= 100.0): tmp = x + (math.tanh((t / y)) * (z * y)) else: tmp = x + (y * (z * ((t / y) - math.tanh((x / y))))) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if ((t <= -8e-222) || !(t <= 100.0)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))); else tmp = Float64(x + Float64(y * Float64(z * Float64(Float64(t / y) - tanh(Float64(x / y)))))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -8e-222) || ~((t <= 100.0))) tmp = x + (tanh((t / y)) * (z * y)); else tmp = x + (y * (z * ((t / y) - tanh((x / y))))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[Or[LessEqual[t, -8e-222], N[Not[LessEqual[t, 100.0]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z * 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 -8 \cdot 10^{-222} \lor \neg \left(t \leq 100\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\end{array}
\end{array}
if t < -8.00000000000000038e-222 or 100 < t Initial program 96.8%
associate-*l*97.8%
Simplified97.8%
Taylor expanded in x around 0 15.1%
*-commutative15.1%
associate-*r*15.0%
associate-/r*15.0%
div-sub15.0%
rec-exp15.0%
rec-exp15.0%
Simplified86.5%
if -8.00000000000000038e-222 < t < 100Initial program 89.2%
associate-*l*97.7%
Simplified97.7%
Taylor expanded in t around 0 89.8%
Final simplification87.4%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 6e-231) x (if (<= y 1.5e+185) (+ 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 <= 6e-231) {
tmp = x;
} else if (y <= 1.5e+185) {
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 <= 6d-231) then
tmp = x
else if (y <= 1.5d+185) 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 <= 6e-231) {
tmp = x;
} else if (y <= 1.5e+185) {
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 <= 6e-231: tmp = x elif y <= 1.5e+185: 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 <= 6e-231) tmp = x; elseif (y <= 1.5e+185) 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 <= 6e-231) tmp = x; elseif (y <= 1.5e+185) 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, 6e-231], x, If[LessEqual[y, 1.5e+185], 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 6 \cdot 10^{-231}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+185}:\\
\;\;\;\;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 < 6.0000000000000005e-231Initial program 93.5%
Taylor expanded in x around inf 63.0%
if 6.0000000000000005e-231 < y < 1.49999999999999997e185Initial program 97.8%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around 0 30.8%
*-commutative30.8%
associate-*r*30.8%
associate-/r*30.8%
div-sub30.8%
rec-exp30.8%
rec-exp30.8%
Simplified85.8%
if 1.49999999999999997e185 < y Initial program 90.2%
+-commutative90.2%
*-commutative90.2%
associate-*l*95.2%
fma-def95.2%
Simplified95.2%
Taylor expanded in y around inf 100.0%
Final simplification73.7%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 2.7e+63) x (if (<= y 1.85e+191) (+ x (* z t)) (if (<= y 3.2e+301) (* z (- t x)) x))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.7e+63) {
tmp = x;
} else if (y <= 1.85e+191) {
tmp = x + (z * t);
} else if (y <= 3.2e+301) {
tmp = z * (t - x);
} else {
tmp = 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 <= 2.7d+63) then
tmp = x
else if (y <= 1.85d+191) then
tmp = x + (z * t)
else if (y <= 3.2d+301) then
tmp = z * (t - x)
else
tmp = 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 <= 2.7e+63) {
tmp = x;
} else if (y <= 1.85e+191) {
tmp = x + (z * t);
} else if (y <= 3.2e+301) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 2.7e+63: tmp = x elif y <= 1.85e+191: tmp = x + (z * t) elif y <= 3.2e+301: tmp = z * (t - x) else: tmp = x return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 2.7e+63) tmp = x; elseif (y <= 1.85e+191) tmp = Float64(x + Float64(z * t)); elseif (y <= 3.2e+301) tmp = Float64(z * Float64(t - x)); else tmp = x; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.7e+63) tmp = x; elseif (y <= 1.85e+191) tmp = x + (z * t); elseif (y <= 3.2e+301) tmp = z * (t - x); else tmp = x; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 2.7e+63], x, If[LessEqual[y, 1.85e+191], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+301], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], x]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.7 \cdot 10^{+63}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+191}:\\
\;\;\;\;x + z \cdot t\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+301}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < 2.70000000000000017e63 or 3.2000000000000002e301 < y Initial program 95.4%
Taylor expanded in x around inf 65.6%
if 2.70000000000000017e63 < y < 1.85000000000000009e191Initial program 93.9%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in x around 0 38.2%
*-commutative38.2%
associate-*r*38.1%
associate-/r*38.1%
div-sub38.1%
rec-exp38.2%
rec-exp38.2%
Simplified81.4%
Taylor expanded in y around inf 66.7%
if 1.85000000000000009e191 < y < 3.2000000000000002e301Initial program 88.5%
+-commutative88.5%
*-commutative88.5%
associate-*l*94.3%
fma-def94.3%
Simplified94.3%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 77.6%
Final simplification66.6%
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(if (<= y 2.1e+67)
x
(if (<= y 1.06e+192)
(+ x (* z t))
(if (<= y 1.1e+287) (* z (- t x)) (- x (* z x))))))y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.1e+67) {
tmp = x;
} else if (y <= 1.06e+192) {
tmp = x + (z * t);
} else if (y <= 1.1e+287) {
tmp = z * (t - x);
} else {
tmp = x - (z * 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 <= 2.1d+67) then
tmp = x
else if (y <= 1.06d+192) then
tmp = x + (z * t)
else if (y <= 1.1d+287) then
tmp = z * (t - x)
else
tmp = x - (z * 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 <= 2.1e+67) {
tmp = x;
} else if (y <= 1.06e+192) {
tmp = x + (z * t);
} else if (y <= 1.1e+287) {
tmp = z * (t - x);
} else {
tmp = x - (z * x);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 2.1e+67: tmp = x elif y <= 1.06e+192: tmp = x + (z * t) elif y <= 1.1e+287: tmp = z * (t - x) else: tmp = x - (z * x) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 2.1e+67) tmp = x; elseif (y <= 1.06e+192) tmp = Float64(x + Float64(z * t)); elseif (y <= 1.1e+287) tmp = Float64(z * Float64(t - x)); else tmp = Float64(x - Float64(z * x)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.1e+67) tmp = x; elseif (y <= 1.06e+192) tmp = x + (z * t); elseif (y <= 1.1e+287) tmp = z * (t - x); else tmp = x - (z * x); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 2.1e+67], x, If[LessEqual[y, 1.06e+192], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+287], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+67}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.06 \cdot 10^{+192}:\\
\;\;\;\;x + z \cdot t\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+287}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < 2.1000000000000001e67Initial program 95.3%
Taylor expanded in x around inf 65.5%
if 2.1000000000000001e67 < y < 1.06000000000000006e192Initial program 93.9%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in x around 0 38.2%
*-commutative38.2%
associate-*r*38.1%
associate-/r*38.1%
div-sub38.1%
rec-exp38.2%
rec-exp38.2%
Simplified81.4%
Taylor expanded in y around inf 66.7%
if 1.06000000000000006e192 < y < 1.10000000000000002e287Initial program 87.0%
+-commutative87.0%
*-commutative87.0%
associate-*l*93.6%
fma-def93.6%
Simplified93.6%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 81.2%
if 1.10000000000000002e287 < y Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in t around 0 83.8%
+-commutative83.8%
mul-1-neg83.8%
unsub-neg83.8%
Simplified83.8%
Final simplification66.8%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 3.3e+72) x (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.3e+72) {
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.3d+72) 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.3e+72) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 3.3e+72: 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.3e+72) 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.3e+72) 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.3e+72], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3 \cdot 10^{+72}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.3e72Initial program 95.4%
Taylor expanded in x around inf 65.6%
if 3.3e72 < y Initial program 92.0%
+-commutative92.0%
*-commutative92.0%
associate-*l*98.0%
fma-def98.0%
Simplified98.0%
Taylor expanded in y around inf 80.7%
Final simplification68.5%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 6e+107) x (* z (- t x))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6e+107) {
tmp = x;
} else {
tmp = 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 <= 6d+107) then
tmp = x
else
tmp = 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 <= 6e+107) {
tmp = x;
} else {
tmp = z * (t - x);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 6e+107: tmp = x else: tmp = z * (t - x) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 6e+107) tmp = x; else tmp = 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 <= 6e+107) tmp = x; else tmp = 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, 6e+107], x, N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6 \cdot 10^{+107}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 6.00000000000000046e107Initial program 95.1%
Taylor expanded in x around inf 64.6%
if 6.00000000000000046e107 < y Initial program 92.9%
+-commutative92.9%
*-commutative92.9%
associate-*l*97.6%
fma-def97.6%
Simplified97.6%
Taylor expanded in y around inf 84.3%
Taylor expanded in z around inf 56.3%
Final simplification63.3%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 7.6e+191) x (* z (- x))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.6e+191) {
tmp = x;
} else {
tmp = z * -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 <= 7.6d+191) then
tmp = x
else
tmp = z * -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 <= 7.6e+191) {
tmp = x;
} else {
tmp = z * -x;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 7.6e+191: tmp = x else: tmp = z * -x return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 7.6e+191) tmp = x; else tmp = Float64(z * Float64(-x)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 7.6e+191) tmp = x; else tmp = z * -x; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 7.6e+191], x, N[(z * (-x)), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.6 \cdot 10^{+191}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\end{array}
\end{array}
if y < 7.5999999999999996e191Initial program 95.1%
Taylor expanded in x around inf 62.8%
if 7.5999999999999996e191 < y Initial program 89.1%
+-commutative89.1%
*-commutative89.1%
associate-*l*94.6%
fma-def94.6%
Simplified94.6%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 73.7%
Taylor expanded in t around 0 30.5%
mul-1-neg30.5%
distribute-rgt-neg-in30.5%
Simplified30.5%
Final simplification60.5%
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 94.7%
Taylor expanded in x around inf 60.2%
Final simplification60.2%
(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 2023199
(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))))))