numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
roots/newton_raphson.cpp

Example to use newton_raphson class.

/*
* Copyright 2021 MusicScience37 (Kenta Kabashima)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "../configure_logging.h"
auto main() -> int {
configure_logging();
constexpr double target = 3.0;
finder.init(target);
finder.solve();
const auto logger = num_collect::logging::logger();
logger.info()("solver: {:15}", finder.variable());
const double reference = std::pow(target, 1.0 / 3.0);
logger.info()("std::pow: {:15}", reference);
return 0;
}
Class of loggers.
Definition logger.h:145
Class of Newton-Raphson method.
Class of test function to calculate cubic root of a number.
Definition of cubic_root_test_function class.
Definition of logger class.
Definition of newton_raphson class.