10 #include "gtest/gtest.h" 14 function_f1(Real x1, Real x2, Real & z, Real & dzdx1, Real & dzdx2)
16 z = x2 * x2 - 3 * x2 + 4 * x1 + 2;
22 function_f2(Real x1, Real x2, Real & z, Real & dzdx1, Real & dzdx2)
24 z =
exp(x1 * x2) + x2 *
log(x2);
25 dzdx1 = x2 *
exp(x1 * x2);
26 dzdx2 = x1 *
exp(x1 * x2) +
log(x2) + 1;
43 Real initial_guess = 11;
53 EXPECT_NEAR(
y, soln,
tol);
60 z = 0.8749124087762432;
64 EXPECT_NEAR(
y, soln,
tol);
68 function_g1(Real x1, Real x2, Real & g, Real & dgdx1, Real & dgdx2)
76 function_g2(Real x1, Real x2, Real & g, Real & dgdx1, Real & dgdx2)
78 g = x1 * x1 + x2 * x2 - 4 * x1 * x2 + 2;
79 dgdx1 = 2 * x1 - 4 * x2;
80 dgdx2 = 2 * x2 - 4 * x1;
84 function_g3(Real x1, Real x2, Real & g, Real & dgdx1, Real & dgdx2)
86 g =
exp(x2) + x1 *
log(x1);
127 y1, y2, guess1, guess2, return_x1, return_x2, 1e-8, 1e-8, func1, func2);
131 EXPECT_NEAR(return_x1, x1_soln,
tol);
132 EXPECT_NEAR(return_x2, x2_soln,
tol);
136 y2 = 1.1196002982765987;
138 y1, y2, guess1, guess2, return_x1, return_x2, 1e-8, 1e-8, func1, func3);
141 EXPECT_NEAR(return_x1, x1_soln,
tol);
142 EXPECT_NEAR(return_x2, x2_soln,
tol);
145 y2 = 1.1196002982765987;
147 y1, y2, guess1, guess2, return_x1, return_x2, 1e-8, 1e-8, func2, func3);
150 EXPECT_NEAR(return_x1, x1_soln,
tol);
151 EXPECT_NEAR(return_x2, x2_soln,
tol);
159 y1, y2, guess1, guess2, return_x1, return_x2, 1e-8, 1e-8, func1, func3);
void function_g2(Real x1, Real x2, Real &g, Real &dgdx1, Real &dgdx2)
const std::vector< double > y
void function_g1(Real x1, Real x2, Real &g, Real &dgdx1, Real &dgdx2)
std::pair< T, T > NewtonSolve(const T &x, const T &y, const Real z_initial_guess, const Real tolerance, const Functor &func, const std::string &caller_name, const unsigned int max_its=100)
NewtonSolve does a 1D Newton Solve to solve the equation y = f(x, z) for variable z...
void NewtonSolve2D(const T &f, const T &g, const Real x0, const Real y0, T &x_final, T &y_final, const Real f_tol, const Real g_tol, const Functor1 &func1, const Functor2 &func2, const unsigned int max_its=100)
NewtonSolve2D does a 2D Newton Solve to solve for the x and y such that: f = func1(x, y) and g = func2(x, y).
const std::vector< double > x
Real f(Real x)
Test function for Brents method.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void function_g3(Real x1, Real x2, Real &g, Real &dgdx1, Real &dgdx2)
void function_f2(Real x1, Real x2, Real &z, Real &dzdx1, Real &dzdx2)
TEST(NewtonInversion, NewtonSolve)
Tests the implementation of Newton's method to find the roots of: a polynomial of x and y...
void function_f1(Real x1, Real x2, Real &z, Real &dzdx1, Real &dzdx2)