Tudat/Mathematics/RootFinders/UnitTests/unitTestHalleyRootFinder.cpp
//! Check if Halley method converges on function with zero root (testFunctionWithZeroRoot).
// Not the best test case. Inheritance from old code. Not really relevant anymore. The basic
// idea is that Halley's method should work for both a function that becomes zero, as well as for a
// function that does not become zero. A better case should be written.
Check if Halley method converges on function with zero root (testFunctionWithZeroRoot).
Not the best test case. Inheritance from old code. Not really relevant anymore. The basic
idea is that Halley's method should work for both a function that becomes zero, as well as for a
function that does not become zero. A better case should be written.
Check if Halley method converges on function with zero root ( testFunctionWithZeroRoot ) . Not the best test case . Inheritance from old code . Not really relevant anymore . The basic idea is that Halley ' s method should work for both a function that becomes zero as well as for a function that does not become zero . A better case should be written .
BOOST_AUTO_TEST_CASE( test_halleyRootFinder_testFunctionWithZeroRoot )
{
    std::shared_ptr< TestFunctionWithZeroRoot > testFunction =
            std::make_shared< TestFunctionWithZeroRoot >( 2 );
    HalleyRootFinder::TerminationFunction terminationConditionFunction
            = std::bind( &RootAbsoluteToleranceTerminationCondition< double >::
                           checkTerminationCondition,
                           std::make_shared< RootAbsoluteToleranceTerminationCondition< double > >(
                               1.0e-150 ), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
    HalleyRootFinder halleyRootFinder( terminationConditionFunction );
    const double root = halleyRootFinder.execute( testFunction, testFunction->getInitialGuess( ) );
    BOOST_CHECK_SMALL( root, 1.0e-100 );
    BOOST_CHECK_SMALL( testFunction->evaluate( root ), 1.0e-200 );
}
BOOST_AUTO_TEST_CASE ( test_halleyRootFinder_testFunctionWithZeroRoot ) { std :: shared_ptr < TestFunctionWithZeroRoot > testFunction = std :: make_shared < TestFunctionWithZeroRoot > ( 2 ) ; HalleyRootFinder :: TerminationFunction terminationConditionFunction = std :: bind ( & RootAbsoluteToleranceTerminationCondition < double > :: checkTerminationCondition , std :: make_shared < RootAbsoluteToleranceTerminationCondition < double > > ( 1.0e-150 ) , std :: placeholders :: _1 , std :: placeholders :: _2 , std :: placeholders :: _3 , std :: placeholders :: _4 , std :: placeholders :: _5 ) ; HalleyRootFinder halleyRootFinder ( terminationConditionFunction ) ; const double root = halleyRootFinder . execute ( testFunction , testFunction -> getInitialGuess ( ) ) ; BOOST_CHECK_SMALL ( root , 1.0e-100 ) ; BOOST_CHECK_SMALL ( testFunction -> evaluate ( root ) , 1.0e-200 ) ; }
Check if Halley method converges on function with zero root (testFunctionWithZeroRoot).
Check if Halley method converges on function with zero root ( testFunctionWithZeroRoot ) .
// Create object containing the test functions. // The termination condition. // Test Halley object. // Let the Halley method search for the root. // Check if the result is within the requested accuracy.