spherical-y-scale-shift

Percentage Accurate: 100.0% → 100.0%
Time: 705.0ms
Alternatives: 2
Speedup: 1.0×

Specification

?
\[esp > 0\]
\[esp \cdot \left(angle - phi0\right) \]
(FPCore (angle esp phi0)
  :precision binary64
  (* esp (- angle phi0)))
double code(double angle, double esp, double phi0) {
	return esp * (angle - phi0);
}
real(8) function code(angle, esp, phi0)
use fmin_fmax_functions
    real(8), intent (in) :: angle
    real(8), intent (in) :: esp
    real(8), intent (in) :: phi0
    code = esp * (angle - phi0)
end function
public static double code(double angle, double esp, double phi0) {
	return esp * (angle - phi0);
}
def code(angle, esp, phi0):
	return esp * (angle - phi0)
function code(angle, esp, phi0)
	return Float64(esp * Float64(angle - phi0))
end
function tmp = code(angle, esp, phi0)
	tmp = esp * (angle - phi0);
end
code[angle_, esp_, phi0_] := N[(esp * N[(angle - phi0), $MachinePrecision]), $MachinePrecision]
esp \cdot \left(angle - phi0\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 2 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: 100.0% accurate, 1.0× speedup?

\[esp \cdot \left(angle - phi0\right) \]
(FPCore (angle esp phi0)
  :precision binary64
  (* esp (- angle phi0)))
double code(double angle, double esp, double phi0) {
	return esp * (angle - phi0);
}
real(8) function code(angle, esp, phi0)
use fmin_fmax_functions
    real(8), intent (in) :: angle
    real(8), intent (in) :: esp
    real(8), intent (in) :: phi0
    code = esp * (angle - phi0)
end function
public static double code(double angle, double esp, double phi0) {
	return esp * (angle - phi0);
}
def code(angle, esp, phi0):
	return esp * (angle - phi0)
function code(angle, esp, phi0)
	return Float64(esp * Float64(angle - phi0))
end
function tmp = code(angle, esp, phi0)
	tmp = esp * (angle - phi0);
end
code[angle_, esp_, phi0_] := N[(esp * N[(angle - phi0), $MachinePrecision]), $MachinePrecision]
esp \cdot \left(angle - phi0\right)

Alternative 1: 53.5% accurate, 1.5× speedup?

\[angle \cdot esp \]
(FPCore (angle esp phi0)
  :precision binary64
  (* angle esp))
double code(double angle, double esp, double phi0) {
	return angle * esp;
}
real(8) function code(angle, esp, phi0)
use fmin_fmax_functions
    real(8), intent (in) :: angle
    real(8), intent (in) :: esp
    real(8), intent (in) :: phi0
    code = angle * esp
end function
public static double code(double angle, double esp, double phi0) {
	return angle * esp;
}
def code(angle, esp, phi0):
	return angle * esp
function code(angle, esp, phi0)
	return Float64(angle * esp)
end
function tmp = code(angle, esp, phi0)
	tmp = angle * esp;
end
code[angle_, esp_, phi0_] := N[(angle * esp), $MachinePrecision]
angle \cdot esp
Derivation
  1. Initial program 100.0%

    \[esp \cdot \left(angle - phi0\right) \]
  2. Taylor expanded in angle around inf

    \[\leadsto \color{blue}{angle \cdot esp} \]
  3. Step-by-step derivation
    1. lower-*.f6453.5%

      \[\leadsto angle \cdot \color{blue}{esp} \]
  4. Applied rewrites53.5%

    \[\leadsto \color{blue}{angle \cdot esp} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2025315 
(FPCore (angle esp phi0)
  :name "spherical-y-scale-shift"
  :precision binary64
  :pre (> esp 0.0)
  (* esp (- angle phi0)))