
(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 92.5%
+-commutative92.5%
*-commutative92.5%
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 92.5%
associate-*l*97.4%
Simplified97.4%
Final simplification97.4%
(FPCore (x y z t) :precision binary64 (if (or (<= y -5.6e+131) (not (<= y 2e+79))) (+ x (* z (- t x))) (+ x (* y (* z (tanh (/ t y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -5.6e+131) || !(y <= 2e+79)) {
tmp = x + (z * (t - x));
} else {
tmp = x + (y * (z * tanh((t / 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 ((y <= (-5.6d+131)) .or. (.not. (y <= 2d+79))) then
tmp = x + (z * (t - x))
else
tmp = x + (y * (z * tanh((t / y))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -5.6e+131) || !(y <= 2e+79)) {
tmp = x + (z * (t - x));
} else {
tmp = x + (y * (z * Math.tanh((t / y))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -5.6e+131) or not (y <= 2e+79): tmp = x + (z * (t - x)) else: tmp = x + (y * (z * math.tanh((t / y)))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -5.6e+131) || !(y <= 2e+79)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -5.6e+131) || ~((y <= 2e+79))) tmp = x + (z * (t - x)); else tmp = x + (y * (z * tanh((t / y)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -5.6e+131], N[Not[LessEqual[y, 2e+79]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.6 \cdot 10^{+131} \lor \neg \left(y \leq 2 \cdot 10^{+79}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\end{array}
\end{array}
if y < -5.6000000000000001e131 or 1.99999999999999993e79 < y Initial program 79.3%
+-commutative79.3%
*-commutative79.3%
associate-*l*96.0%
fma-def96.0%
Simplified96.0%
Taylor expanded in y around inf 93.8%
if -5.6000000000000001e131 < y < 1.99999999999999993e79Initial program 100.0%
associate-*l*99.3%
Simplified99.3%
Taylor expanded in x around 0 20.7%
*-commutative20.7%
associate-/r*20.7%
div-sub20.7%
rec-exp20.7%
rec-exp20.7%
tanh-def-a86.4%
Simplified86.4%
Final simplification89.1%
(FPCore (x y z t) :precision binary64 (if (or (<= y -9.5e+130) (not (<= y 3e+79))) (+ x (* z (- t x))) (+ x (* (tanh (/ t y)) (* z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -9.5e+130) || !(y <= 3e+79)) {
tmp = x + (z * (t - x));
} else {
tmp = x + (tanh((t / 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 ((y <= (-9.5d+130)) .or. (.not. (y <= 3d+79))) then
tmp = x + (z * (t - x))
else
tmp = x + (tanh((t / y)) * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -9.5e+130) || !(y <= 3e+79)) {
tmp = x + (z * (t - x));
} else {
tmp = x + (Math.tanh((t / y)) * (z * y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -9.5e+130) or not (y <= 3e+79): tmp = x + (z * (t - x)) else: tmp = x + (math.tanh((t / y)) * (z * y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -9.5e+130) || !(y <= 3e+79)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -9.5e+130) || ~((y <= 3e+79))) tmp = x + (z * (t - x)); else tmp = x + (tanh((t / y)) * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -9.5e+130], N[Not[LessEqual[y, 3e+79]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{+130} \lor \neg \left(y \leq 3 \cdot 10^{+79}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if y < -9.5000000000000009e130 or 2.99999999999999974e79 < y Initial program 79.3%
+-commutative79.3%
*-commutative79.3%
associate-*l*96.0%
fma-def96.0%
Simplified96.0%
Taylor expanded in y around inf 93.8%
if -9.5000000000000009e130 < y < 2.99999999999999974e79Initial program 100.0%
associate-*l*99.3%
Simplified99.3%
Taylor expanded in x around 0 20.7%
*-commutative20.7%
associate-/r*20.7%
div-sub20.7%
rec-exp20.7%
rec-exp20.7%
tanh-def-a86.4%
Simplified86.4%
Taylor expanded in z around 0 20.7%
associate-*r*20.7%
associate-/r*20.7%
div-sub20.7%
rec-exp20.7%
rec-exp20.7%
tanh-def-a87.0%
Simplified87.0%
Final simplification89.5%
(FPCore (x y z t) :precision binary64 (if (or (<= y -7.8e+37) (not (<= y 7.5e-25))) (+ x (* z (- t x))) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -7.8e+37) || !(y <= 7.5e-25)) {
tmp = x + (z * (t - x));
} 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 <= (-7.8d+37)) .or. (.not. (y <= 7.5d-25))) then
tmp = x + (z * (t - x))
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 <= -7.8e+37) || !(y <= 7.5e-25)) {
tmp = x + (z * (t - x));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -7.8e+37) or not (y <= 7.5e-25): tmp = x + (z * (t - x)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -7.8e+37) || !(y <= 7.5e-25)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -7.8e+37) || ~((y <= 7.5e-25))) tmp = x + (z * (t - x)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -7.8e+37], N[Not[LessEqual[y, 7.5e-25]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.8 \cdot 10^{+37} \lor \neg \left(y \leq 7.5 \cdot 10^{-25}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -7.7999999999999997e37 or 7.49999999999999989e-25 < y Initial program 84.6%
+-commutative84.6%
*-commutative84.6%
associate-*l*97.0%
fma-def97.0%
Simplified97.0%
Taylor expanded in y around inf 87.9%
if -7.7999999999999997e37 < y < 7.49999999999999989e-25Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 74.3%
Final simplification81.0%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.2e+109) (not (<= z 1.15e-8))) (* z (- t x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.2e+109) || !(z <= 1.15e-8)) {
tmp = z * (t - x);
} 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 ((z <= (-3.2d+109)) .or. (.not. (z <= 1.15d-8))) then
tmp = z * (t - x)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.2e+109) || !(z <= 1.15e-8)) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.2e+109) or not (z <= 1.15e-8): tmp = z * (t - x) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.2e+109) || !(z <= 1.15e-8)) tmp = Float64(z * Float64(t - x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.2e+109) || ~((z <= 1.15e-8))) tmp = z * (t - x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.2e+109], N[Not[LessEqual[z, 1.15e-8]], $MachinePrecision]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \cdot 10^{+109} \lor \neg \left(z \leq 1.15 \cdot 10^{-8}\right):\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3.2000000000000001e109 or 1.15e-8 < z Initial program 85.1%
+-commutative85.1%
*-commutative85.1%
associate-*l*96.9%
fma-def96.9%
Simplified96.9%
Taylor expanded in y around inf 51.2%
Taylor expanded in z around inf 51.2%
if -3.2000000000000001e109 < z < 1.15e-8Initial program 99.2%
+-commutative99.2%
*-commutative99.2%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 85.9%
Final simplification69.4%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.7e-28) (not (<= y 1.45e-13))) (+ x (* z t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.7e-28) || !(y <= 1.45e-13)) {
tmp = x + (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 <= (-2.7d-28)) .or. (.not. (y <= 1.45d-13))) then
tmp = x + (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 <= -2.7e-28) || !(y <= 1.45e-13)) {
tmp = x + (z * t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.7e-28) or not (y <= 1.45e-13): tmp = x + (z * t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.7e-28) || !(y <= 1.45e-13)) tmp = Float64(x + Float64(z * t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -2.7e-28) || ~((y <= 1.45e-13))) tmp = x + (z * t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.7e-28], N[Not[LessEqual[y, 1.45e-13]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-28} \lor \neg \left(y \leq 1.45 \cdot 10^{-13}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -2.6999999999999999e-28 or 1.4499999999999999e-13 < y Initial program 86.2%
associate-*l*95.9%
Simplified95.9%
Taylor expanded in x around 0 31.9%
*-commutative31.9%
associate-/r*31.9%
div-sub31.9%
rec-exp32.0%
rec-exp32.0%
tanh-def-a73.7%
Simplified73.7%
Taylor expanded in y around inf 65.9%
if -2.6999999999999999e-28 < y < 1.4499999999999999e-13Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 76.8%
Final simplification70.9%
(FPCore (x y z t) :precision binary64 (if (<= z -1e+218) (* z t) (if (<= z 7.5e+162) x (* x (- z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1e+218) {
tmp = z * t;
} else if (z <= 7.5e+162) {
tmp = x;
} else {
tmp = x * -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 (z <= (-1d+218)) then
tmp = z * t
else if (z <= 7.5d+162) then
tmp = x
else
tmp = x * -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1e+218) {
tmp = z * t;
} else if (z <= 7.5e+162) {
tmp = x;
} else {
tmp = x * -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1e+218: tmp = z * t elif z <= 7.5e+162: tmp = x else: tmp = x * -z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1e+218) tmp = Float64(z * t); elseif (z <= 7.5e+162) tmp = x; else tmp = Float64(x * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1e+218) tmp = z * t; elseif (z <= 7.5e+162) tmp = x; else tmp = x * -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1e+218], N[(z * t), $MachinePrecision], If[LessEqual[z, 7.5e+162], x, N[(x * (-z)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+218}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{+162}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < -1.00000000000000008e218Initial program 85.0%
associate-*l*94.7%
Simplified94.7%
Taylor expanded in x around 0 3.2%
*-commutative3.2%
associate-/r*3.2%
div-sub3.2%
rec-exp3.3%
rec-exp3.3%
tanh-def-a55.7%
Simplified55.7%
Taylor expanded in y around inf 40.0%
Taylor expanded in t around inf 39.5%
if -1.00000000000000008e218 < z < 7.50000000000000033e162Initial program 95.5%
+-commutative95.5%
*-commutative95.5%
associate-*l*98.6%
fma-def98.6%
Simplified98.6%
Taylor expanded in z around 0 69.4%
if 7.50000000000000033e162 < z Initial program 81.3%
+-commutative81.3%
*-commutative81.3%
associate-*l*97.6%
fma-def97.6%
Simplified97.6%
Taylor expanded in y around inf 64.6%
Taylor expanded in z around inf 64.6%
Taylor expanded in t around 0 38.3%
associate-*r*38.3%
mul-1-neg38.3%
Simplified38.3%
Final simplification62.2%
(FPCore (x y z t) :precision binary64 (if (<= x -1.75e-165) x (if (<= x 3.7e-167) (* z t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.75e-165) {
tmp = x;
} else if (x <= 3.7e-167) {
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 (x <= (-1.75d-165)) then
tmp = x
else if (x <= 3.7d-167) 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 (x <= -1.75e-165) {
tmp = x;
} else if (x <= 3.7e-167) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.75e-165: tmp = x elif x <= 3.7e-167: tmp = z * t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.75e-165) tmp = x; elseif (x <= 3.7e-167) tmp = Float64(z * t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.75e-165) tmp = x; elseif (x <= 3.7e-167) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.75e-165], x, If[LessEqual[x, 3.7e-167], N[(z * t), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-165}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-167}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.7500000000000001e-165 or 3.7000000000000003e-167 < x Initial program 92.1%
+-commutative92.1%
*-commutative92.1%
associate-*l*98.6%
fma-def98.6%
Simplified98.6%
Taylor expanded in z around 0 68.7%
if -1.7500000000000001e-165 < x < 3.7000000000000003e-167Initial program 93.5%
associate-*l*95.2%
Simplified95.2%
Taylor expanded in x around 0 17.5%
*-commutative17.5%
associate-/r*17.5%
div-sub17.4%
rec-exp17.4%
rec-exp17.4%
tanh-def-a86.8%
Simplified86.8%
Taylor expanded in y around inf 52.3%
Taylor expanded in t around inf 40.2%
Final simplification61.9%
(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 92.5%
+-commutative92.5%
*-commutative92.5%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in z around 0 57.4%
Final simplification57.4%
(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 2023196
(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))))))