Peano
Loading...
Searching...
No Matches
MathDerivatives.cpph
Go to the documentation of this file.
1// This file is part of the ExaHyPE2 project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3
4#include <cmath>
5
6static inline auto numerics::_3D::partialX(auto f, const auto x, const auto y, const auto t) {
7 const auto h = std::cbrt(std::numeric_limits<decltype(x)>::epsilon()) * std::max(1.0, std::abs(x));
8 return (f(x + h, y, t) - f(x - h, y, t)) / (2.0 * h);
9};
10
24static inline auto numerics::_3D::partialY(auto f, const auto x, const auto y, const auto t) {
25 const auto h = std::cbrt(std::numeric_limits<decltype(y)>::epsilon()) * std::max(1.0, std::abs(y));
26 return (f(x, y + h, t) - f(x, y - h, t)) / (2.0 * h);
27};
28
42static inline auto numerics::_3D::partialT(auto f, const auto x, const auto y, const auto t) {
43 const auto h = std::cbrt(std::numeric_limits<decltype(t)>::epsilon()) * std::max(1.0, std::abs(t));
44 return (f(x, y, t + h) - f(x, y, t - h)) / (2.0 * h);
45};
static auto partialT(auto f, const auto x, const auto y, const auto t)
Approximates the partial derivative ∂f/∂t of a function f(x, y, t) using central differences.
static auto partialX(auto f, const auto x, const auto y, const auto t)
Approximates the partial derivative ∂f/∂x of a function f(x, y, t) using central differences.
static auto partialY(auto f, const auto x, const auto y, const auto t)
Approximates the partial derivative ∂f/∂y of a function f(x, y, t) using central differences.