Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3

?

Percentage Accurate: 97.2% → 99.7%
Time: 22.4s
Precision: binary64
Cost: 832

?

\[x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}} \]
\[x + a \cdot \frac{z - y}{\left(t - z\right) + 1} \]
(FPCore (x y z t a)
 :precision binary64
 (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))
(FPCore (x y z t a)
 :precision binary64
 (+ x (* a (/ (- z y) (+ (- t z) 1.0)))))
double code(double x, double y, double z, double t, double a) {
	return x - ((y - z) / (((t - z) + 1.0) / a));
}
double code(double x, double y, double z, double t, double a) {
	return x + (a * ((z - y) / ((t - z) + 1.0)));
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = x - ((y - z) / (((t - z) + 1.0d0) / a))
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = x + (a * ((z - y) / ((t - z) + 1.0d0)))
end function
public static double code(double x, double y, double z, double t, double a) {
	return x - ((y - z) / (((t - z) + 1.0) / a));
}
public static double code(double x, double y, double z, double t, double a) {
	return x + (a * ((z - y) / ((t - z) + 1.0)));
}
def code(x, y, z, t, a):
	return x - ((y - z) / (((t - z) + 1.0) / a))
def code(x, y, z, t, a):
	return x + (a * ((z - y) / ((t - z) + 1.0)))
function code(x, y, z, t, a)
	return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a)))
end
function code(x, y, z, t, a)
	return Float64(x + Float64(a * Float64(Float64(z - y) / Float64(Float64(t - z) + 1.0))))
end
function tmp = code(x, y, z, t, a)
	tmp = x - ((y - z) / (((t - z) + 1.0) / a));
end
function tmp = code(x, y, z, t, a)
	tmp = x + (a * ((z - y) / ((t - z) + 1.0)));
end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := N[(x + N[(a * N[(N[(z - y), $MachinePrecision] / N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
x + a \cdot \frac{z - y}{\left(t - z\right) + 1}

Local Percentage Accuracy?

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.

Herbie found 18 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each of Herbie's proposed alternatives. Up and to the right is better. Each dot represents an alternative program; the red square represents the initial program.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original97.2%
Target99.7%
Herbie99.7%
\[x - \frac{y - z}{\left(t - z\right) + 1} \cdot a \]

Derivation?

  1. Initial program 96.5%

    \[x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}} \]
  2. Simplified99.5%

    \[\leadsto \color{blue}{x - \frac{y - z}{\left(t - z\right) + 1} \cdot a} \]
    Step-by-step derivation

    [Start]96.5

    \[ x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}} \]

    associate-/r/ [=>]99.5

    \[ x - \color{blue}{\frac{y - z}{\left(t - z\right) + 1} \cdot a} \]
  3. Final simplification99.5%

    \[\leadsto x + a \cdot \frac{z - y}{\left(t - z\right) + 1} \]

Alternatives

Alternative 1
Accuracy89.1%
Cost1232
\[\begin{array}{l} t_1 := x + z \cdot \frac{a}{\left(t - z\right) + 1}\\ \mathbf{if}\;t \leq -1.06 \cdot 10^{+160}:\\ \;\;\;\;x - y \cdot \frac{a}{t + 1}\\ \mathbf{elif}\;t \leq -3.8 \cdot 10^{+30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -9 \cdot 10^{+29}:\\ \;\;\;\;y \cdot \left(a \cdot \frac{1}{-1 + \left(z - t\right)}\right)\\ \mathbf{elif}\;t \leq 3500000000:\\ \;\;\;\;x + a \cdot \frac{z - y}{1 - z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Accuracy72.5%
Cost1108
\[\begin{array}{l} t_1 := x + \frac{z \cdot a}{t}\\ t_2 := x - \left(y - z\right) \cdot a\\ \mathbf{if}\;z \leq -4.7 \cdot 10^{+39}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-306}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{-202}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-44}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+77}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 3
Accuracy73.1%
Cost1108
\[\begin{array}{l} t_1 := x - \left(y - z\right) \cdot a\\ \mathbf{if}\;z \leq -4.9 \cdot 10^{+39}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-302}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{-222}:\\ \;\;\;\;x - \frac{y \cdot a}{t}\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+78}:\\ \;\;\;\;x + \frac{z \cdot a}{t}\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 4
Accuracy73.2%
Cost1108
\[\begin{array}{l} t_1 := x - \left(y - z\right) \cdot a\\ \mathbf{if}\;z \leq -1.15 \cdot 10^{+40}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{-306}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{-221}:\\ \;\;\;\;x - \frac{y \cdot a}{t}\\ \mathbf{elif}\;z \leq 1.76 \cdot 10^{-43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{+84}:\\ \;\;\;\;x + z \cdot \frac{a}{t}\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 5
Accuracy87.2%
Cost1036
\[\begin{array}{l} t_1 := x + a \cdot \frac{z - y}{-z}\\ \mathbf{if}\;z \leq -3 \cdot 10^{+64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.76 \cdot 10^{-43}:\\ \;\;\;\;x - y \cdot \frac{a}{t + 1}\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+84}:\\ \;\;\;\;x + \frac{z - y}{\frac{t}{a}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Accuracy61.0%
Cost976
\[\begin{array}{l} t_1 := y \cdot \frac{a}{-1 - t}\\ \mathbf{if}\;z \leq -9 \cdot 10^{+34}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq -8.2 \cdot 10^{-170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-134}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-75}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+84}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 7
Accuracy83.5%
Cost972
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{+66}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-43}:\\ \;\;\;\;x - y \cdot \frac{a}{t + 1}\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{+83}:\\ \;\;\;\;x - \frac{\left(y - z\right) \cdot a}{t}\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 8
Accuracy83.7%
Cost972
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+68}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq 6.4 \cdot 10^{-45}:\\ \;\;\;\;x - y \cdot \frac{a}{t + 1}\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{+96}:\\ \;\;\;\;x + \frac{z - y}{\frac{t}{a}}\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 9
Accuracy91.2%
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -1.8 \cdot 10^{+84}:\\ \;\;\;\;x + a \cdot \frac{z - y}{-z}\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+73}:\\ \;\;\;\;x - \frac{y - z}{\frac{t + 1}{a}}\\ \mathbf{else}:\\ \;\;\;\;x + a \cdot \frac{z - y}{1 - z}\\ \end{array} \]
Alternative 10
Accuracy61.5%
Cost844
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+34}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq -4.2 \cdot 10^{-159}:\\ \;\;\;\;y \cdot \frac{a}{-1 - t}\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{+77}:\\ \;\;\;\;x + \frac{z \cdot a}{t}\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 11
Accuracy83.0%
Cost844
\[\begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{+65}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq 1.76 \cdot 10^{-43}:\\ \;\;\;\;x - y \cdot \frac{a}{t + 1}\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{+84}:\\ \;\;\;\;x + z \cdot \frac{a}{t}\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 12
Accuracy54.3%
Cost656
\[\begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{-132}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.06 \cdot 10^{-261}:\\ \;\;\;\;-a\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-174}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-85}:\\ \;\;\;\;-a\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Accuracy64.3%
Cost588
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+34}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-13}:\\ \;\;\;\;y \cdot \left(-a\right)\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+84}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 14
Accuracy64.4%
Cost588
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+34}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-13}:\\ \;\;\;\;a \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+84}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 15
Accuracy64.4%
Cost588
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+34}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-13}:\\ \;\;\;\;y \cdot \frac{a}{z}\\ \mathbf{elif}\;z \leq 1.62 \cdot 10^{+84}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 16
Accuracy65.7%
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+65}:\\ \;\;\;\;x - a\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+84}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - a\\ \end{array} \]
Alternative 17
Accuracy54.0%
Cost64
\[x \]

Reproduce?

herbie shell --seed 2023160 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (- x (* (/ (- y z) (+ (- t z) 1.0)) a))

  (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))