+
+energy_fem :: (Arity m, Arity n, Arity l,
+ Algebraic.C a, Eq a, RealField.C a, ToRational.C a)
+ => PDE a
+ -> Params m n (S l) a
+ -> a
+energy_fem pde params =
+ (coefficients pde params) `dot` (big_F pde params)
+
+
+relative_error :: forall m n l a.
+ (Arity m, Arity n, Arity l,
+ Algebraic.C a, Eq a, RealField.C a, ToRational.C a)
+ => PDE a
+ -> Params m n (S l) a
+ -> a -- ^ The energy norm of the true solution @u@
+ -> a
+relative_error pde params energy_true =
+ cent * sqrt(energy_true - (energy_fem pde params)/energy_true)
+ where
+ cent = fromInteger 100
+
+
+
+relative_error_pointwise :: forall m n l a.
+ (Arity m, Arity n, Arity l,
+ Algebraic.C a, Eq a, RealField.C a, ToRational.C a)
+ => PDE a
+ -> Params m n (S l) a
+ -> (a -> a) -- ^ The true solution @u@
+ -> a -- ^ The point @x@ at which to compute the error.
+ -> a
+relative_error_pointwise pde params u x =
+ cent * ( abs $ (u x) - u_fem ) / ( abs $ u x )
+ where
+ u_fem = evaluate' (solution pde params) x
+ cent = fromInteger 100