[wpimath] Clean up math comments (#4252)

This commit is contained in:
Tyler Veness
2022-05-20 15:16:56 -07:00
committed by GitHub
parent fff4d1f44e
commit 5aa67f56e6
25 changed files with 141 additions and 132 deletions

View File

@@ -207,14 +207,14 @@ TEST(LinearFilterOutputTest, CentralFiniteDifference) {
return std::log(x);
},
[](double x) {
// df/dx = 1 / x
// df/dx = 1/x
return 1.0 / x;
},
h, 1.0, 20.0);
AssertCentralResults<2, 5>(
[](double x) {
// f(x) = x^2
// f(x) = x²
return x * x;
},
[](double x) {
@@ -240,7 +240,7 @@ TEST(LinearFilterOutputTest, CentralFiniteDifference) {
return std::log(x);
},
[](double x) {
// d²f/dx² = -1 /
// d²f/dx² = -1/
return -1.0 / (x * x);
},
h, 1.0, 20.0);
@@ -280,14 +280,14 @@ TEST(LinearFilterOutputTest, BackwardFiniteDifference) {
return std::log(x);
},
[](double x) {
// df/dx = 1 / x
// df/dx = 1/x
return 1.0 / x;
},
h, 1.0, 20.0);
AssertBackwardResults<2, 4>(
[](double x) {
// f(x) = x^2
// f(x) = x²
return x * x;
},
[](double x) {
@@ -313,7 +313,7 @@ TEST(LinearFilterOutputTest, BackwardFiniteDifference) {
return std::log(x);
},
[](double x) {
// d²f/dx² = -1 /
// d²f/dx² = -1/
return -1.0 / (x * x);
},
h, 1.0, 20.0);

View File

@@ -10,18 +10,17 @@
namespace {
frc::Vectord<1> RungeKuttaTimeVaryingSolution(double t) {
return frc::Vectord<1>{12.0 * std::exp(t) /
(std::pow(std::exp(t) + 1.0, 2.0))};
return frc::Vectord<1>{12.0 * std::exp(t) / std::pow(std::exp(t) + 1.0, 2.0)};
}
} // namespace
// Tests RK4 with a time varying solution. From
// http://www2.hawaii.edu/~jmcfatri/math407/RungeKuttaTest.html:
// x' = x (2 / (e^t + 1) - 1)
// x' = x (2/(eᵗ + 1) - 1)
//
// The true (analytical) solution is:
//
// x(t) = 12 * e^t / ((e^t + 1)^2)
// x(t) = 12eᵗ/((e + 1)²)
TEST(RungeKuttaTimeVaryingTest, RungeKuttaTimeVarying) {
frc::Vectord<1> y0 = RungeKuttaTimeVaryingSolution(5.0);