Logarithmic Transform

Percentage Accurate: 42.1% → 99.3%
Time: 33.8s
Alternatives: 8
Speedup: 5.0×

Specification

?
\[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
(FPCore (c x y)
  :precision binary64
  :pre TRUE
  (* c (log (+ 1.0 (* (- (pow E x) 1.0) y)))))
double code(double c, double x, double y) {
	return c * log((1.0 + ((pow(((double) M_E), x) - 1.0) * y)));
}
public static double code(double c, double x, double y) {
	return c * Math.log((1.0 + ((Math.pow(Math.E, x) - 1.0) * y)));
}
def code(c, x, y):
	return c * math.log((1.0 + ((math.pow(math.e, x) - 1.0) * y)))
function code(c, x, y)
	return Float64(c * log(Float64(1.0 + Float64(Float64((exp(1) ^ x) - 1.0) * y))))
end
function tmp = code(c, x, y)
	tmp = c * log((1.0 + (((2.71828182845904523536 ^ x) - 1.0) * y)));
end
code[c_, x_, y_] := N[(c * N[Log[N[(1.0 + N[(N[(N[Power[E, x], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
f(c, x, y):
	c in [-inf, +inf],
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(c, x, y: real): real =
	c * (ln(((1) + (((exp(1) ^ x) - (1)) * y))))
END code
c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right)

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 42.1% accurate, 1.0× speedup?

\[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
(FPCore (c x y)
  :precision binary64
  :pre TRUE
  (* c (log (+ 1.0 (* (- (pow E x) 1.0) y)))))
double code(double c, double x, double y) {
	return c * log((1.0 + ((pow(((double) M_E), x) - 1.0) * y)));
}
public static double code(double c, double x, double y) {
	return c * Math.log((1.0 + ((Math.pow(Math.E, x) - 1.0) * y)));
}
def code(c, x, y):
	return c * math.log((1.0 + ((math.pow(math.e, x) - 1.0) * y)))
function code(c, x, y)
	return Float64(c * log(Float64(1.0 + Float64(Float64((exp(1) ^ x) - 1.0) * y))))
end
function tmp = code(c, x, y)
	tmp = c * log((1.0 + (((2.71828182845904523536 ^ x) - 1.0) * y)));
end
code[c_, x_, y_] := N[(c * N[Log[N[(1.0 + N[(N[(N[Power[E, x], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
f(c, x, y):
	c in [-inf, +inf],
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(c, x, y: real): real =
	c * (ln(((1) + (((exp(1) ^ x) - (1)) * y))))
END code
c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right)

Alternative 1: 99.3% accurate, 1.1× speedup?

\[\begin{array}{l} t_0 := c \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(x\right) \cdot y\right)\\ \mathbf{if}\;y \leq -1.5511526834195688 \cdot 10^{-28}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.106409269880449 \cdot 10^{-55}:\\ \;\;\;\;y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (c x y)
  :precision binary64
  :pre TRUE
  (let* ((t_0 (* c (log1p (* (expm1 x) y)))))
  (if (<= y -1.5511526834195688e-28)
    t_0
    (if (<= y 1.106409269880449e-55) (* y (* c (expm1 x))) t_0))))
double code(double c, double x, double y) {
	double t_0 = c * log1p((expm1(x) * y));
	double tmp;
	if (y <= -1.5511526834195688e-28) {
		tmp = t_0;
	} else if (y <= 1.106409269880449e-55) {
		tmp = y * (c * expm1(x));
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double c, double x, double y) {
	double t_0 = c * Math.log1p((Math.expm1(x) * y));
	double tmp;
	if (y <= -1.5511526834195688e-28) {
		tmp = t_0;
	} else if (y <= 1.106409269880449e-55) {
		tmp = y * (c * Math.expm1(x));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(c, x, y):
	t_0 = c * math.log1p((math.expm1(x) * y))
	tmp = 0
	if y <= -1.5511526834195688e-28:
		tmp = t_0
	elif y <= 1.106409269880449e-55:
		tmp = y * (c * math.expm1(x))
	else:
		tmp = t_0
	return tmp
function code(c, x, y)
	t_0 = Float64(c * log1p(Float64(expm1(x) * y)))
	tmp = 0.0
	if (y <= -1.5511526834195688e-28)
		tmp = t_0;
	elseif (y <= 1.106409269880449e-55)
		tmp = Float64(y * Float64(c * expm1(x)));
	else
		tmp = t_0;
	end
	return tmp
end
code[c_, x_, y_] := Block[{t$95$0 = N[(c * N[Log[1 + N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.5511526834195688e-28], t$95$0, If[LessEqual[y, 1.106409269880449e-55], N[(y * N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(c, x, y):
	c in [-inf, +inf],
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(c, x, y: real): real =
	LET t_0 = (c * (ln(((((exp(x)) - (1)) * y) + (1))))) IN
		LET tmp_1 = IF (y <= (1106409269880448986171765822828396570300838916253403248766447726993267927555191844216655416972111226111754746531116047854664735489932931417587924638468166449456475675106048583984375e-235)) THEN (y * (c * ((exp(x)) - (1)))) ELSE t_0 ENDIF IN
		LET tmp = IF (y <= (-1551152683419568771045439616240171027412485134580889752304752284356722060766620163718698677257634699344635009765625e-142)) THEN t_0 ELSE tmp_1 ENDIF IN
	tmp
END code
\begin{array}{l}
t_0 := c \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(x\right) \cdot y\right)\\
\mathbf{if}\;y \leq -1.5511526834195688 \cdot 10^{-28}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.106409269880449 \cdot 10^{-55}:\\
\;\;\;\;y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.5511526834195688e-28 or 1.106409269880449e-55 < y

    1. Initial program 42.1%

      \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
    2. Applied rewrites93.3%

      \[\leadsto c \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(x\right) \cdot y\right) \]

    if -1.5511526834195688e-28 < y < 1.106409269880449e-55

    1. Initial program 42.1%

      \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
    2. Taylor expanded in y around 0

      \[\leadsto c \cdot \left(y \cdot \left(e^{x} - 1\right)\right) \]
    3. Applied rewrites74.1%

      \[\leadsto c \cdot \left(y \cdot \mathsf{expm1}\left(x\right)\right) \]
    4. Applied rewrites77.6%

      \[\leadsto y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 88.4% accurate, 1.2× speedup?

\[\begin{array}{l} t_0 := c \cdot \log \left(\mathsf{fma}\left(\mathsf{expm1}\left(x\right), y, 1\right)\right)\\ \mathbf{if}\;y \leq -5.756465638514478 \cdot 10^{+95}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 6.6993600723541415 \cdot 10^{+153}:\\ \;\;\;\;y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (c x y)
  :precision binary64
  :pre TRUE
  (let* ((t_0 (* c (log (fma (expm1 x) y 1.0)))))
  (if (<= y -5.756465638514478e+95)
    t_0
    (if (<= y 6.6993600723541415e+153) (* y (* c (expm1 x))) t_0))))
double code(double c, double x, double y) {
	double t_0 = c * log(fma(expm1(x), y, 1.0));
	double tmp;
	if (y <= -5.756465638514478e+95) {
		tmp = t_0;
	} else if (y <= 6.6993600723541415e+153) {
		tmp = y * (c * expm1(x));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(c, x, y)
	t_0 = Float64(c * log(fma(expm1(x), y, 1.0)))
	tmp = 0.0
	if (y <= -5.756465638514478e+95)
		tmp = t_0;
	elseif (y <= 6.6993600723541415e+153)
		tmp = Float64(y * Float64(c * expm1(x)));
	else
		tmp = t_0;
	end
	return tmp
end
code[c_, x_, y_] := Block[{t$95$0 = N[(c * N[Log[N[(N[(Exp[x] - 1), $MachinePrecision] * y + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.756465638514478e+95], t$95$0, If[LessEqual[y, 6.6993600723541415e+153], N[(y * N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(c, x, y):
	c in [-inf, +inf],
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(c, x, y: real): real =
	LET t_0 = (c * (ln(((((exp(x)) - (1)) * y) + (1))))) IN
		LET tmp_1 = IF (y <= (6699360072354141475203966126958235020504119986664746420655450416218605553402243332468594199816495235077034820225283496654424754774302170343137135535587328)) THEN (y * (c * ((exp(x)) - (1)))) ELSE t_0 ENDIF IN
		LET tmp = IF (y <= (-575646563851447818334308706974014366108583700322314004965891818191341923109222785033876646395904)) THEN t_0 ELSE tmp_1 ENDIF IN
	tmp
END code
\begin{array}{l}
t_0 := c \cdot \log \left(\mathsf{fma}\left(\mathsf{expm1}\left(x\right), y, 1\right)\right)\\
\mathbf{if}\;y \leq -5.756465638514478 \cdot 10^{+95}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 6.6993600723541415 \cdot 10^{+153}:\\
\;\;\;\;y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.7564656385144782e95 or 6.6993600723541415e153 < y

    1. Initial program 42.1%

      \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
    2. Applied rewrites51.5%

      \[\leadsto c \cdot \log \left(\mathsf{fma}\left(\mathsf{expm1}\left(x\right), y, 1\right)\right) \]

    if -5.7564656385144782e95 < y < 6.6993600723541415e153

    1. Initial program 42.1%

      \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
    2. Taylor expanded in y around 0

      \[\leadsto c \cdot \left(y \cdot \left(e^{x} - 1\right)\right) \]
    3. Applied rewrites74.1%

      \[\leadsto c \cdot \left(y \cdot \mathsf{expm1}\left(x\right)\right) \]
    4. Applied rewrites77.6%

      \[\leadsto y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 79.8% accurate, 1.8× speedup?

\[\begin{array}{l} \mathbf{if}\;y \leq 6.6993600723541415 \cdot 10^{+153}:\\ \;\;\;\;y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot \log \left(1 + x \cdot y\right)\\ \end{array} \]
(FPCore (c x y)
  :precision binary64
  :pre TRUE
  (if (<= y 6.6993600723541415e+153)
  (* y (* c (expm1 x)))
  (* c (log (+ 1.0 (* x y))))))
double code(double c, double x, double y) {
	double tmp;
	if (y <= 6.6993600723541415e+153) {
		tmp = y * (c * expm1(x));
	} else {
		tmp = c * log((1.0 + (x * y)));
	}
	return tmp;
}
public static double code(double c, double x, double y) {
	double tmp;
	if (y <= 6.6993600723541415e+153) {
		tmp = y * (c * Math.expm1(x));
	} else {
		tmp = c * Math.log((1.0 + (x * y)));
	}
	return tmp;
}
def code(c, x, y):
	tmp = 0
	if y <= 6.6993600723541415e+153:
		tmp = y * (c * math.expm1(x))
	else:
		tmp = c * math.log((1.0 + (x * y)))
	return tmp
function code(c, x, y)
	tmp = 0.0
	if (y <= 6.6993600723541415e+153)
		tmp = Float64(y * Float64(c * expm1(x)));
	else
		tmp = Float64(c * log(Float64(1.0 + Float64(x * y))));
	end
	return tmp
end
code[c_, x_, y_] := If[LessEqual[y, 6.6993600723541415e+153], N[(y * N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c * N[Log[N[(1.0 + N[(x * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
f(c, x, y):
	c in [-inf, +inf],
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(c, x, y: real): real =
	LET tmp = IF (y <= (6699360072354141475203966126958235020504119986664746420655450416218605553402243332468594199816495235077034820225283496654424754774302170343137135535587328)) THEN (y * (c * ((exp(x)) - (1)))) ELSE (c * (ln(((1) + (x * y))))) ENDIF IN
	tmp
END code
\begin{array}{l}
\mathbf{if}\;y \leq 6.6993600723541415 \cdot 10^{+153}:\\
\;\;\;\;y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;c \cdot \log \left(1 + x \cdot y\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 6.6993600723541415e153

    1. Initial program 42.1%

      \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
    2. Taylor expanded in y around 0

      \[\leadsto c \cdot \left(y \cdot \left(e^{x} - 1\right)\right) \]
    3. Applied rewrites74.1%

      \[\leadsto c \cdot \left(y \cdot \mathsf{expm1}\left(x\right)\right) \]
    4. Applied rewrites77.6%

      \[\leadsto y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right) \]

    if 6.6993600723541415e153 < y

    1. Initial program 42.1%

      \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
    2. Taylor expanded in x around 0

      \[\leadsto c \cdot \log \left(1 + x \cdot y\right) \]
    3. Applied rewrites40.1%

      \[\leadsto c \cdot \log \left(1 + x \cdot y\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 77.6% accurate, 2.0× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -7.417339803987706 \cdot 10^{-58}:\\ \;\;\;\;c \cdot \left(y \cdot \mathsf{expm1}\left(x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(c \cdot y\right)\\ \end{array} \]
(FPCore (c x y)
  :precision binary64
  :pre TRUE
  (if (<= x -7.417339803987706e-58) (* c (* y (expm1 x))) (* x (* c y))))
double code(double c, double x, double y) {
	double tmp;
	if (x <= -7.417339803987706e-58) {
		tmp = c * (y * expm1(x));
	} else {
		tmp = x * (c * y);
	}
	return tmp;
}
public static double code(double c, double x, double y) {
	double tmp;
	if (x <= -7.417339803987706e-58) {
		tmp = c * (y * Math.expm1(x));
	} else {
		tmp = x * (c * y);
	}
	return tmp;
}
def code(c, x, y):
	tmp = 0
	if x <= -7.417339803987706e-58:
		tmp = c * (y * math.expm1(x))
	else:
		tmp = x * (c * y)
	return tmp
function code(c, x, y)
	tmp = 0.0
	if (x <= -7.417339803987706e-58)
		tmp = Float64(c * Float64(y * expm1(x)));
	else
		tmp = Float64(x * Float64(c * y));
	end
	return tmp
end
code[c_, x_, y_] := If[LessEqual[x, -7.417339803987706e-58], N[(c * N[(y * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(c * y), $MachinePrecision]), $MachinePrecision]]
f(c, x, y):
	c in [-inf, +inf],
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(c, x, y: real): real =
	LET tmp = IF (x <= (-7417339803987706051609638428185765246820801495451024508716982989045805325943245960443833233383756116685077234171247789697125728316515361223759499054164479048267821781337261199951171875e-241)) THEN (c * (y * ((exp(x)) - (1)))) ELSE (x * (c * y)) ENDIF IN
	tmp
END code
\begin{array}{l}
\mathbf{if}\;x \leq -7.417339803987706 \cdot 10^{-58}:\\
\;\;\;\;c \cdot \left(y \cdot \mathsf{expm1}\left(x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(c \cdot y\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.4173398039877061e-58

    1. Initial program 42.1%

      \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
    2. Taylor expanded in y around 0

      \[\leadsto c \cdot \left(y \cdot \left(e^{x} - 1\right)\right) \]
    3. Applied rewrites74.1%

      \[\leadsto c \cdot \left(y \cdot \mathsf{expm1}\left(x\right)\right) \]

    if -7.4173398039877061e-58 < x

    1. Initial program 42.1%

      \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
    2. Taylor expanded in x around 0

      \[\leadsto c \cdot \left(x \cdot y\right) \]
    3. Applied rewrites56.2%

      \[\leadsto c \cdot \left(x \cdot y\right) \]
    4. Applied rewrites62.3%

      \[\leadsto x \cdot \left(c \cdot y\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 77.0% accurate, 2.5× speedup?

\[y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right) \]
(FPCore (c x y)
  :precision binary64
  :pre TRUE
  (* y (* c (expm1 x))))
double code(double c, double x, double y) {
	return y * (c * expm1(x));
}
public static double code(double c, double x, double y) {
	return y * (c * Math.expm1(x));
}
def code(c, x, y):
	return y * (c * math.expm1(x))
function code(c, x, y)
	return Float64(y * Float64(c * expm1(x)))
end
code[c_, x_, y_] := N[(y * N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(c, x, y):
	c in [-inf, +inf],
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(c, x, y: real): real =
	y * (c * ((exp(x)) - (1)))
END code
y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right)
Derivation
  1. Initial program 42.1%

    \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
  2. Taylor expanded in y around 0

    \[\leadsto c \cdot \left(y \cdot \left(e^{x} - 1\right)\right) \]
  3. Applied rewrites74.1%

    \[\leadsto c \cdot \left(y \cdot \mathsf{expm1}\left(x\right)\right) \]
  4. Applied rewrites77.6%

    \[\leadsto y \cdot \left(c \cdot \mathsf{expm1}\left(x\right)\right) \]
  5. Add Preprocessing

Alternative 6: 62.3% accurate, 5.0× speedup?

\[x \cdot \left(c \cdot y\right) \]
(FPCore (c x y)
  :precision binary64
  :pre TRUE
  (* x (* c y)))
double code(double c, double x, double y) {
	return x * (c * y);
}
real(8) function code(c, x, y)
use fmin_fmax_functions
    real(8), intent (in) :: c
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x * (c * y)
end function
public static double code(double c, double x, double y) {
	return x * (c * y);
}
def code(c, x, y):
	return x * (c * y)
function code(c, x, y)
	return Float64(x * Float64(c * y))
end
function tmp = code(c, x, y)
	tmp = x * (c * y);
end
code[c_, x_, y_] := N[(x * N[(c * y), $MachinePrecision]), $MachinePrecision]
f(c, x, y):
	c in [-inf, +inf],
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(c, x, y: real): real =
	x * (c * y)
END code
x \cdot \left(c \cdot y\right)
Derivation
  1. Initial program 42.1%

    \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
  2. Taylor expanded in x around 0

    \[\leadsto c \cdot \left(x \cdot y\right) \]
  3. Applied rewrites56.2%

    \[\leadsto c \cdot \left(x \cdot y\right) \]
  4. Applied rewrites62.3%

    \[\leadsto x \cdot \left(c \cdot y\right) \]
  5. Add Preprocessing

Alternative 7: 58.0% accurate, 3.3× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -5.742794795096544 \cdot 10^{+167}:\\ \;\;\;\;0 \cdot c\\ \mathbf{else}:\\ \;\;\;\;c \cdot \left(x \cdot y\right)\\ \end{array} \]
(FPCore (c x y)
  :precision binary64
  :pre TRUE
  (if (<= x -5.742794795096544e+167) (* 0.0 c) (* c (* x y))))
double code(double c, double x, double y) {
	double tmp;
	if (x <= -5.742794795096544e+167) {
		tmp = 0.0 * c;
	} else {
		tmp = c * (x * y);
	}
	return tmp;
}
real(8) function code(c, x, y)
use fmin_fmax_functions
    real(8), intent (in) :: c
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-5.742794795096544d+167)) then
        tmp = 0.0d0 * c
    else
        tmp = c * (x * y)
    end if
    code = tmp
end function
public static double code(double c, double x, double y) {
	double tmp;
	if (x <= -5.742794795096544e+167) {
		tmp = 0.0 * c;
	} else {
		tmp = c * (x * y);
	}
	return tmp;
}
def code(c, x, y):
	tmp = 0
	if x <= -5.742794795096544e+167:
		tmp = 0.0 * c
	else:
		tmp = c * (x * y)
	return tmp
function code(c, x, y)
	tmp = 0.0
	if (x <= -5.742794795096544e+167)
		tmp = Float64(0.0 * c);
	else
		tmp = Float64(c * Float64(x * y));
	end
	return tmp
end
function tmp_2 = code(c, x, y)
	tmp = 0.0;
	if (x <= -5.742794795096544e+167)
		tmp = 0.0 * c;
	else
		tmp = c * (x * y);
	end
	tmp_2 = tmp;
end
code[c_, x_, y_] := If[LessEqual[x, -5.742794795096544e+167], N[(0.0 * c), $MachinePrecision], N[(c * N[(x * y), $MachinePrecision]), $MachinePrecision]]
f(c, x, y):
	c in [-inf, +inf],
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(c, x, y: real): real =
	LET tmp = IF (x <= (-574279479509654428513738203990391290412983179384704553627057515023638265121933065921031923646839306755009345843997374291291218962910957683421804481399581996264607186944)) THEN ((0) * c) ELSE (c * (x * y)) ENDIF IN
	tmp
END code
\begin{array}{l}
\mathbf{if}\;x \leq -5.742794795096544 \cdot 10^{+167}:\\
\;\;\;\;0 \cdot c\\

\mathbf{else}:\\
\;\;\;\;c \cdot \left(x \cdot y\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.7427947950965443e167

    1. Initial program 42.1%

      \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
    2. Applied rewrites51.4%

      \[\leadsto c \cdot \left(\log \left(\left|\mathsf{fma}\left(\mathsf{expm1}\left(x\right), y + y, 2\right)\right|\right) - \log 2\right) \]
    3. Applied rewrites25.6%

      \[\leadsto \mathsf{fma}\left(c, \log \left(\left|\mathsf{fma}\left(\mathsf{expm1}\left(x\right), y + y, 2\right)\right|\right), c \cdot \log 0.5\right) \]
    4. Taylor expanded in x around 0

      \[\leadsto c \cdot \log \frac{1}{2} + c \cdot \log 2 \]
    5. Applied rewrites5.9%

      \[\leadsto \mathsf{fma}\left(c, \log 0.5, c \cdot \log 2\right) \]
    6. Applied rewrites31.2%

      \[\leadsto 0 \cdot c \]

    if -5.7427947950965443e167 < x

    1. Initial program 42.1%

      \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
    2. Taylor expanded in x around 0

      \[\leadsto c \cdot \left(x \cdot y\right) \]
    3. Applied rewrites56.2%

      \[\leadsto c \cdot \left(x \cdot y\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 31.2% accurate, 8.8× speedup?

\[0 \cdot c \]
(FPCore (c x y)
  :precision binary64
  :pre TRUE
  (* 0.0 c))
double code(double c, double x, double y) {
	return 0.0 * c;
}
real(8) function code(c, x, y)
use fmin_fmax_functions
    real(8), intent (in) :: c
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 0.0d0 * c
end function
public static double code(double c, double x, double y) {
	return 0.0 * c;
}
def code(c, x, y):
	return 0.0 * c
function code(c, x, y)
	return Float64(0.0 * c)
end
function tmp = code(c, x, y)
	tmp = 0.0 * c;
end
code[c_, x_, y_] := N[(0.0 * c), $MachinePrecision]
f(c, x, y):
	c in [-inf, +inf],
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(c, x, y: real): real =
	(0) * c
END code
0 \cdot c
Derivation
  1. Initial program 42.1%

    \[c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right) \]
  2. Applied rewrites51.4%

    \[\leadsto c \cdot \left(\log \left(\left|\mathsf{fma}\left(\mathsf{expm1}\left(x\right), y + y, 2\right)\right|\right) - \log 2\right) \]
  3. Applied rewrites25.6%

    \[\leadsto \mathsf{fma}\left(c, \log \left(\left|\mathsf{fma}\left(\mathsf{expm1}\left(x\right), y + y, 2\right)\right|\right), c \cdot \log 0.5\right) \]
  4. Taylor expanded in x around 0

    \[\leadsto c \cdot \log \frac{1}{2} + c \cdot \log 2 \]
  5. Applied rewrites5.9%

    \[\leadsto \mathsf{fma}\left(c, \log 0.5, c \cdot \log 2\right) \]
  6. Applied rewrites31.2%

    \[\leadsto 0 \cdot c \]
  7. Add Preprocessing

Developer Target 1: 93.3% accurate, 1.4× speedup?

\[c \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(x\right) \cdot y\right) \]
(FPCore (c x y)
  :precision binary64
  :pre TRUE
  (* c (log1p (* (expm1 x) y))))
double code(double c, double x, double y) {
	return c * log1p((expm1(x) * y));
}
public static double code(double c, double x, double y) {
	return c * Math.log1p((Math.expm1(x) * y));
}
def code(c, x, y):
	return c * math.log1p((math.expm1(x) * y))
function code(c, x, y)
	return Float64(c * log1p(Float64(expm1(x) * y)))
end
code[c_, x_, y_] := N[(c * N[Log[1 + N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
f(c, x, y):
	c in [-inf, +inf],
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(c, x, y: real): real =
	c * (ln(((((exp(x)) - (1)) * y) + (1))))
END code
c \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(x\right) \cdot y\right)

Reproduce

?
herbie shell --seed 2026089 +o generate:egglog
(FPCore (c x y)
  :name "Logarithmic Transform"
  :precision binary64

  :alt
  (* c (log1p (* (expm1 x) y)))

  (* c (log (+ 1.0 (* (- (pow E x) 1.0) y)))))