Peano
CentralDifferencePartial2D.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cmath>
4 
19  inline auto partialX(auto f, const auto x, const auto y, const auto t) {
20  const auto h = std::sqrt(std::numeric_limits<decltype(x)>::epsilon()) * std::max(1.0, std::abs(x));
21  return (f(x + h, y, t) - f(x - h, y, t)) / (2.0 * h);
22  };
23 
37  inline auto partialY(auto f, const auto x, const auto y, const auto t) {
38  const auto h = std::sqrt(std::numeric_limits<decltype(y)>::epsilon()) * std::max(1.0, std::abs(y));
39  return (f(x, y + h, t) - f(x, y - h, t)) / (2.0 * h);
40  };
41 
55  inline auto partialT(auto f, const auto x, const auto y, const auto t) {
56  const auto h = std::sqrt(std::numeric_limits<decltype(t)>::epsilon()) * std::max(1.0, std::abs(t));
57  return (f(x, y, t + h) - f(x, y, t - h)) / (2.0 * h);
58  };
59 } // namespace math::differentiation::numeric_3D::central_difference
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.
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.
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.
h
Definition: swe.py:79