diff --git a/src/samplefunctional.hh b/src/samplefunctional.hh
index 6f7033f9685dcef42e8507076cb0c27f5372838d..28188fdb25ac3c6ebdd7f71ca19dedeb4dcd3746 100644
--- a/src/samplefunctional.hh
+++ b/src/samplefunctional.hh
@@ -46,17 +46,19 @@ class SampleFunctional {
 
     SmallVector const pg = upperGradient(x);
     SmallVector const mg = lowerGradient(x);
+    double const pgx = pg * x;
+    double const mgx = mg * x;
     // TODO: collinearity checks suck
-    if (pg * x == pg.two_norm() * x.two_norm() &&
-        -(mg * x) == mg.two_norm() * x.two_norm()) {
+    if (pgx == pg.two_norm() * x.two_norm() &&
+        -mgx == mg.two_norm() * x.two_norm()) {
       ret = SmallVector(0.0);
       return;
-    } else if (pg * x >= 0 && mg * x >= 0) {
+    } else if (pgx >= 0 && mgx >= 0) {
       ret = pg;
       Dune::dverb << "## Directional derivative (as per scalar product w/ "
                      "semigradient): " << -(ret * mg)
                   << " (coordinates of the restriction)" << std::endl;
-    } else if (pg * x <= 0 && mg * x <= 0) {
+    } else if (pgx <= 0 && mgx <= 0) {
       ret = mg;
       Dune::dverb << "## Directional derivative (as per scalar product w/ "
                      "semigradient): " << -(ret * pg)