
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
(FPCore (x y z t) :precision binary64 (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 93.3%
+-commutative93.3%
*-commutative93.3%
associate-*l*98.2%
fma-def98.2%
Simplified98.2%
Final simplification98.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}
Initial program 93.3%
associate-*l*97.4%
Simplified97.4%
Final simplification97.4%
(FPCore (x y z t) :precision binary64 (if (<= y 1.9e-188) x (if (<= y 1.66e+118) (+ x (* y (* z (tanh (/ t y))))) (fma z (- t x) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.9e-188) {
tmp = x;
} else if (y <= 1.66e+118) {
tmp = x + (y * (z * tanh((t / y))));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.9e-188) tmp = x; elseif (y <= 1.66e+118) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.9e-188], x, If[LessEqual[y, 1.66e+118], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{-188}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.66 \cdot 10^{+118}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.9e-188Initial program 93.8%
associate-*l*98.2%
Simplified98.2%
Taylor expanded in x around inf 63.3%
if 1.9e-188 < y < 1.66e118Initial program 98.3%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in x around 0 29.5%
associate-/r*29.5%
rec-exp29.6%
div-sub29.5%
rec-exp29.5%
tanh-def-a90.1%
Simplified90.1%
if 1.66e118 < y Initial program 82.9%
associate-*l*90.4%
Simplified90.4%
Taylor expanded in y around inf 90.0%
+-commutative90.0%
fma-def90.0%
Simplified90.0%
Final simplification73.7%
(FPCore (x y z t) :precision binary64 (if (<= y 8.8e+57) x (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.8e+57) {
tmp = x;
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 8.8e+57) tmp = x; else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.8e+57], x, N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.8 \cdot 10^{+57}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 8.8000000000000003e57Initial program 95.3%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around inf 63.9%
if 8.8000000000000003e57 < y Initial program 85.3%
associate-*l*92.8%
Simplified92.8%
Taylor expanded in y around inf 86.5%
+-commutative86.5%
fma-def86.5%
Simplified86.5%
Final simplification68.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* z t))))
(if (<= y 2.05e+59)
x
(if (<= y 1.25e+162)
t_1
(if (<= y 1.85e+177)
(- x (* z x))
(if (or (<= y 7e+263) (not (<= y 1.85e+278))) t_1 (* z (- t x))))))))
double code(double x, double y, double z, double t) {
double t_1 = x + (z * t);
double tmp;
if (y <= 2.05e+59) {
tmp = x;
} else if (y <= 1.25e+162) {
tmp = t_1;
} else if (y <= 1.85e+177) {
tmp = x - (z * x);
} else if ((y <= 7e+263) || !(y <= 1.85e+278)) {
tmp = t_1;
} else {
tmp = 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) :: t_1
real(8) :: tmp
t_1 = x + (z * t)
if (y <= 2.05d+59) then
tmp = x
else if (y <= 1.25d+162) then
tmp = t_1
else if (y <= 1.85d+177) then
tmp = x - (z * x)
else if ((y <= 7d+263) .or. (.not. (y <= 1.85d+278))) then
tmp = t_1
else
tmp = z * (t - x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + (z * t);
double tmp;
if (y <= 2.05e+59) {
tmp = x;
} else if (y <= 1.25e+162) {
tmp = t_1;
} else if (y <= 1.85e+177) {
tmp = x - (z * x);
} else if ((y <= 7e+263) || !(y <= 1.85e+278)) {
tmp = t_1;
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (z * t) tmp = 0 if y <= 2.05e+59: tmp = x elif y <= 1.25e+162: tmp = t_1 elif y <= 1.85e+177: tmp = x - (z * x) elif (y <= 7e+263) or not (y <= 1.85e+278): tmp = t_1 else: tmp = z * (t - x) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(z * t)) tmp = 0.0 if (y <= 2.05e+59) tmp = x; elseif (y <= 1.25e+162) tmp = t_1; elseif (y <= 1.85e+177) tmp = Float64(x - Float64(z * x)); elseif ((y <= 7e+263) || !(y <= 1.85e+278)) tmp = t_1; else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (z * t); tmp = 0.0; if (y <= 2.05e+59) tmp = x; elseif (y <= 1.25e+162) tmp = t_1; elseif (y <= 1.85e+177) tmp = x - (z * x); elseif ((y <= 7e+263) || ~((y <= 1.85e+278))) tmp = t_1; else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 2.05e+59], x, If[LessEqual[y, 1.25e+162], t$95$1, If[LessEqual[y, 1.85e+177], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 7e+263], N[Not[LessEqual[y, 1.85e+278]], $MachinePrecision]], t$95$1, N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + z \cdot t\\
\mathbf{if}\;y \leq 2.05 \cdot 10^{+59}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+162}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+177}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+263} \lor \neg \left(y \leq 1.85 \cdot 10^{+278}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.05e59Initial program 95.3%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around inf 63.9%
if 2.05e59 < y < 1.2499999999999999e162 or 1.85000000000000007e177 < y < 6.99999999999999997e263 or 1.85000000000000011e278 < y Initial program 90.0%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in x around 0 42.1%
associate-/r*42.1%
rec-exp42.2%
div-sub42.1%
rec-exp42.1%
tanh-def-a86.0%
Simplified86.0%
Taylor expanded in y around inf 77.8%
if 1.2499999999999999e162 < y < 1.85000000000000007e177Initial program 86.0%
+-commutative86.0%
*-commutative86.0%
associate-*l*86.0%
fma-def86.0%
Simplified86.0%
Taylor expanded in y around inf 85.7%
Taylor expanded in t around 0 85.7%
+-commutative85.7%
mul-1-neg85.7%
unsub-neg85.7%
Simplified85.7%
if 6.99999999999999997e263 < y < 1.85000000000000011e278Initial program 63.0%
+-commutative63.0%
*-commutative63.0%
associate-*l*75.9%
fma-def75.9%
Simplified75.9%
Taylor expanded in y around inf 99.8%
Taylor expanded in z around inf 99.8%
Final simplification67.6%
(FPCore (x y z t) :precision binary64 (if (<= y 3.2e+59) x (if (or (<= y 4.5e+263) (not (<= y 9e+277))) (+ x (* z t)) (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.2e+59) {
tmp = x;
} else if ((y <= 4.5e+263) || !(y <= 9e+277)) {
tmp = x + (z * t);
} else {
tmp = 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 <= 3.2d+59) then
tmp = x
else if ((y <= 4.5d+263) .or. (.not. (y <= 9d+277))) then
tmp = x + (z * t)
else
tmp = 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 <= 3.2e+59) {
tmp = x;
} else if ((y <= 4.5e+263) || !(y <= 9e+277)) {
tmp = x + (z * t);
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.2e+59: tmp = x elif (y <= 4.5e+263) or not (y <= 9e+277): tmp = x + (z * t) else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.2e+59) tmp = x; elseif ((y <= 4.5e+263) || !(y <= 9e+277)) tmp = Float64(x + Float64(z * t)); else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.2e+59) tmp = x; elseif ((y <= 4.5e+263) || ~((y <= 9e+277))) tmp = x + (z * t); else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.2e+59], x, If[Or[LessEqual[y, 4.5e+263], N[Not[LessEqual[y, 9e+277]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{+59}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+263} \lor \neg \left(y \leq 9 \cdot 10^{+277}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.19999999999999982e59Initial program 95.3%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around inf 63.9%
if 3.19999999999999982e59 < y < 4.50000000000000014e263 or 8.99999999999999983e277 < y Initial program 87.4%
associate-*l*93.9%
Simplified93.9%
Taylor expanded in x around 0 41.6%
associate-/r*41.6%
rec-exp41.7%
div-sub41.6%
rec-exp41.6%
tanh-def-a79.8%
Simplified79.8%
Taylor expanded in y around inf 73.1%
if 4.50000000000000014e263 < y < 8.99999999999999983e277Initial program 72.1%
+-commutative72.1%
*-commutative72.1%
associate-*l*86.4%
fma-def86.4%
Simplified86.4%
Taylor expanded in y around inf 99.8%
Taylor expanded in z around inf 99.8%
Final simplification66.5%
(FPCore (x y z t) :precision binary64 (if (or (<= z -8e+91) (not (<= z 5.5e+75))) (* z (- t x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -8e+91) || !(z <= 5.5e+75)) {
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 <= (-8d+91)) .or. (.not. (z <= 5.5d+75))) 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 <= -8e+91) || !(z <= 5.5e+75)) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -8e+91) or not (z <= 5.5e+75): tmp = z * (t - x) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -8e+91) || !(z <= 5.5e+75)) 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 <= -8e+91) || ~((z <= 5.5e+75))) tmp = z * (t - x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -8e+91], N[Not[LessEqual[z, 5.5e+75]], $MachinePrecision]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{+91} \lor \neg \left(z \leq 5.5 \cdot 10^{+75}\right):\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -8.00000000000000064e91 or 5.5000000000000001e75 < z Initial program 86.0%
+-commutative86.0%
*-commutative86.0%
associate-*l*96.2%
fma-def96.2%
Simplified96.2%
Taylor expanded in y around inf 50.1%
Taylor expanded in z around inf 50.1%
if -8.00000000000000064e91 < z < 5.5000000000000001e75Initial program 98.2%
associate-*l*98.3%
Simplified98.3%
Taylor expanded in x around inf 81.1%
Final simplification68.5%
(FPCore (x y z t) :precision binary64 (if (<= y 8.8e+58) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.8e+58) {
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 <= 8.8d+58) 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 <= 8.8e+58) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8.8e+58: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8.8e+58) 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 <= 8.8e+58) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.8e+58], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.8 \cdot 10^{+58}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 8.8000000000000003e58Initial program 95.3%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around inf 63.9%
if 8.8000000000000003e58 < y Initial program 85.3%
+-commutative85.3%
*-commutative85.3%
associate-*l*92.9%
fma-def92.9%
Simplified92.9%
Taylor expanded in y around inf 86.5%
Final simplification68.4%
(FPCore (x y z t) :precision binary64 (if (<= z 4.1e+83) x (if (<= z 7.8e+251) (* x (- z)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 4.1e+83) {
tmp = x;
} else if (z <= 7.8e+251) {
tmp = x * -z;
} 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 <= 4.1d+83) then
tmp = x
else if (z <= 7.8d+251) then
tmp = x * -z
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 <= 4.1e+83) {
tmp = x;
} else if (z <= 7.8e+251) {
tmp = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 4.1e+83: tmp = x elif z <= 7.8e+251: tmp = x * -z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 4.1e+83) tmp = x; elseif (z <= 7.8e+251) tmp = Float64(x * Float64(-z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 4.1e+83) tmp = x; elseif (z <= 7.8e+251) tmp = x * -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 4.1e+83], x, If[LessEqual[z, 7.8e+251], N[(x * (-z)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.1 \cdot 10^{+83}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 7.8 \cdot 10^{+251}:\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < 4.1000000000000001e83 or 7.79999999999999951e251 < z Initial program 94.5%
associate-*l*97.8%
Simplified97.8%
Taylor expanded in x around inf 68.3%
if 4.1000000000000001e83 < z < 7.79999999999999951e251Initial program 87.7%
+-commutative87.7%
*-commutative87.7%
associate-*l*95.9%
fma-def95.9%
Simplified95.9%
Taylor expanded in y around inf 51.5%
Taylor expanded in z around inf 51.5%
Taylor expanded in t around 0 36.3%
mul-1-neg36.3%
distribute-rgt-neg-out36.3%
Simplified36.3%
Final simplification62.4%
(FPCore (x y z t) :precision binary64 (if (<= z 1.2e+171) x (if (<= z 8e+286) (* z t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 1.2e+171) {
tmp = x;
} else if (z <= 8e+286) {
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 (z <= 1.2d+171) then
tmp = x
else if (z <= 8d+286) 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 (z <= 1.2e+171) {
tmp = x;
} else if (z <= 8e+286) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 1.2e+171: tmp = x elif z <= 8e+286: tmp = z * t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 1.2e+171) tmp = x; elseif (z <= 8e+286) tmp = Float64(z * t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 1.2e+171) tmp = x; elseif (z <= 8e+286) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 1.2e+171], x, If[LessEqual[z, 8e+286], N[(z * t), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.2 \cdot 10^{+171}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 8 \cdot 10^{+286}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < 1.19999999999999999e171 or 8.00000000000000026e286 < z Initial program 93.7%
associate-*l*97.2%
Simplified97.2%
Taylor expanded in x around inf 64.2%
if 1.19999999999999999e171 < z < 8.00000000000000026e286Initial program 89.2%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in y around inf 56.2%
*-commutative56.2%
associate-/l*56.2%
Simplified56.2%
associate-*r/45.6%
Applied egg-rr45.6%
associate-/r/45.6%
Applied egg-rr45.6%
Taylor expanded in x around 0 37.8%
*-commutative37.8%
Simplified37.8%
Final simplification61.5%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 93.3%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in x around inf 58.6%
Final simplification58.6%
(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 2023221
(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))))))