diff --git a/test/kepDE.cpp b/test/kepDE.cpp index c7a72f6d8..fca7bffda 100644 --- a/test/kepDE.cpp +++ b/test/kepDE.cpp @@ -76,40 +76,40 @@ TEST_CASE("kepDE def ctor") REQUIRE(k.args()[2] == 0_dbl); } -#if 0 - -TEST_CASE("kepF diff") +TEST_CASE("kepDE diff") { auto [x, y, z] = make_vars("x", "y", "z"); { - REQUIRE(diff(kepF(x, y, z), x) - == -cos(kepF(x, y, z)) / (1_dbl - x * sin(kepF(x, y, z)) - y * cos(kepF(x, y, z)))); - REQUIRE(diff(kepF(x, y, z), y) - == sin(kepF(x, y, z)) / (1_dbl - x * sin(kepF(x, y, z)) - y * cos(kepF(x, y, z)))); - REQUIRE(diff(kepF(x, y, z), z) == 1_dbl / (1_dbl - x * sin(kepF(x, y, z)) - y * cos(kepF(x, y, z)))); - auto F = kepF(x * x, x * y, x * z); - REQUIRE(diff(F, x) == (y * sin(F) - 2_dbl * x * cos(F) + z) / (1_dbl - x * x * sin(F) - x * y * cos(F))); - REQUIRE(diff(F, y) == (x * sin(F)) / (1_dbl - x * x * sin(F) - x * y * cos(F))); + REQUIRE(diff(kepDE(x, y, z), x) + == (cos(kepDE(x, y, z)) - 1_dbl) / (1_dbl + x * sin(kepDE(x, y, z)) - y * cos(kepDE(x, y, z)))); + REQUIRE(diff(kepDE(x, y, z), y) + == -sin(kepDE(x, y, z)) / (1_dbl + x * sin(kepDE(x, y, z)) - y * cos(kepDE(x, y, z)))); + REQUIRE(diff(kepDE(x, y, z), z) == 1_dbl / (1_dbl + x * sin(kepDE(x, y, z)) - y * cos(kepDE(x, y, z)))); + auto DE = kepDE(x * x, x * y, x * z); + REQUIRE(diff(DE, x) + == (2_dbl * x * (cos(DE) - 1_dbl) - y * sin(DE) + z) / (1_dbl + x * x * sin(DE) - x * y * cos(DE))); + REQUIRE(diff(DE, y) == (-x * sin(DE)) / (1_dbl + x * x * sin(DE) - x * y * cos(DE))); } { - REQUIRE(diff(kepF(par[0], y, z), par[0]) - == -cos(kepF(par[0], y, z)) / (1_dbl - par[0] * sin(kepF(par[0], y, z)) - y * cos(kepF(par[0], y, z)))); - REQUIRE(diff(kepF(x, par[1], z), par[1]) - == sin(kepF(x, par[1], z)) / (1_dbl - x * sin(kepF(x, par[1], z)) - par[1] * cos(kepF(x, par[1], z)))); - REQUIRE(diff(kepF(x, y, par[2]), par[2]) - == 1_dbl / (1_dbl - x * sin(kepF(x, y, par[2])) - y * cos(kepF(x, y, par[2])))); - auto F = kepF(par[0] * par[0], par[0] * par[1], par[0] * par[2]); - REQUIRE(diff(F, par[0]) - == (par[1] * sin(F) - 2_dbl * par[0] * cos(F) + par[2]) - / (1_dbl - par[0] * par[0] * sin(F) - par[0] * par[1] * cos(F))); - REQUIRE(diff(F, par[1]) == (par[0] * sin(F)) / (1_dbl - par[0] * par[0] * sin(F) - par[0] * par[1] * cos(F))); + REQUIRE(diff(kepDE(par[0], y, z), par[0]) + == (cos(kepDE(par[0], y, z)) - 1_dbl) + / (1_dbl + par[0] * sin(kepDE(par[0], y, z)) - y * cos(kepDE(par[0], y, z)))); + REQUIRE(diff(kepDE(x, par[1], z), par[1]) + == -sin(kepDE(x, par[1], z)) + / (1_dbl + x * sin(kepDE(x, par[1], z)) - par[1] * cos(kepDE(x, par[1], z)))); + REQUIRE(diff(kepDE(x, y, par[2]), par[2]) + == 1_dbl / (1_dbl + x * sin(kepDE(x, y, par[2])) - y * cos(kepDE(x, y, par[2])))); + auto DE = kepDE(par[0] * par[0], par[0] * par[1], par[0] * par[2]); + REQUIRE(diff(DE, par[0]) + == (2_dbl * par[0] * (cos(DE) - 1_dbl) - par[1] * sin(DE) + par[2]) + / (1_dbl + par[0] * par[0] * sin(DE) - par[0] * par[1] * cos(DE))); + REQUIRE(diff(DE, par[1]) + == (-par[0] * sin(DE)) / (1_dbl + par[0] * par[0] * sin(DE) - par[0] * par[1] * cos(DE))); } } -#endif - #define HEYOKA_TEST_KEPDE_OVERLOAD(type) \ { \ auto k = kepDE("x"_var, static_cast(1.1), static_cast(1.3)); \