LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
newton_raphson.hpp
浏览该文件的文档.
1/**
2 * @file newton_raphson.hpp
3 * @brief 数值求根:Newton-Raphson 迭代,二分法,Sturm 实根隔离.
4 */
5#pragma once
6
7#include "symbolic.hpp"
8#include "polynomial.hpp"
9#include "rational.hpp"
10#include "solve_strategies.hpp"
12#include <vector>
13#include <memory>
14#include <string>
15#include <optional>
16#include <utility>
17
18namespace LMCAS {
19
22
23/**
24 * @brief 在受支持的一元表达式域内执行数值求根.
25 *
26 * 多项式输入先由 Sturm 序列隔离实根,再执行受检精化;隔离区间通过
27 * 溢出安全的中点生成 Newton 初值,包括最大有限浮点端点。
28 * 其他输入使用 Newton 初值,缺省初值为零;求值、取消与资源诊断
29 * 均通过 Result 通道返回调用方。
30 *
31 * @see Jacques Charles François Sturm,
32 * "Mémoire sur la résolution des équations numériques," 1829.
33 */
35 const std::shared_ptr<SymbolicExpr>& expr,
36 const std::string& var,
38 const SolveOptions& opts = {});
39
40/**
41 * @brief Numerically solves using an isolated default computation context.
42 */
44 const std::shared_ptr<SymbolicExpr>& expr,
45 const std::string& var,
46 const SolveOptions& opts = {});
47
48/**
49 * @brief Isolates all distinct real roots of an exact rational polynomial.
50 */
53 const Polynomial<Rational>& poly,
55
58
59/**
60 * @brief 带错误传播和资源预算的 Newton-Raphson 迭代.
61 */
63 const std::shared_ptr<SymbolicExpr>& f,
64 const std::shared_ptr<SymbolicExpr>& df,
65 const std::string& var,
66 lmmc_real_t x0,
68 const SolveOptions& opts);
69
71 const std::shared_ptr<SymbolicExpr>& f,
72 const std::shared_ptr<SymbolicExpr>& df,
73 const std::string& var,
74 lmmc_real_t x0,
75 const SolveOptions& opts);
76
77/**
78 * @brief 带区间,错误传播和资源预算的 Newton-Raphson 迭代.
79 */
81 const std::shared_ptr<SymbolicExpr>& f,
82 const std::shared_ptr<SymbolicExpr>& df,
83 const std::string& var,
84 lmmc_real_t x0,
85 lmmc_real_t bracket_lo,
86 lmmc_real_t bracket_hi,
88 const SolveOptions& opts);
89
91 const std::shared_ptr<SymbolicExpr>& f,
92 const std::shared_ptr<SymbolicExpr>& df,
93 const std::string& var,
94 lmmc_real_t x0,
95 lmmc_real_t bracket_lo,
96 lmmc_real_t bracket_hi,
97 const SolveOptions& opts);
98
99/**
100 * @brief 带错误传播和资源预算的二分法求根.
101 */
103 const std::shared_ptr<SymbolicExpr>& f,
104 const std::string& var,
105 lmmc_real_t lo,
106 lmmc_real_t hi,
108 const SolveOptions& opts);
109
111 const std::shared_ptr<SymbolicExpr>& f,
112 const std::string& var,
113 lmmc_real_t lo,
114 lmmc_real_t hi,
115 const SolveOptions& opts);
116
117}
一元多项式模板类
#define LMCAS_API
NumericRootResult newton_raphson_checked(const std::shared_ptr< SymbolicExpr > &function, const std::shared_ptr< SymbolicExpr > &derivative, const std::string &variable, lmmc_real_t initial, lmmc_real_t bracket_lower, lmmc_real_t bracket_upper, ComputationContext &context, const SolveOptions &options)
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
Result< std::vector< std::pair< Rational, Rational > > > isolate_real_roots_checked(const Polynomial< Rational > &polynomial, ComputationContext &context)
Result< std::vector< NumericRoot > > NumericRootsResult
Result< std::optional< NumericRoot > > NumericRootResult
NumericRootResult bisection_checked(const std::shared_ptr< SymbolicExpr > &function, const std::string &variable, lmmc_real_t lower, lmmc_real_t upper, ComputationContext &context, const SolveOptions &options)
NumericRootsResult solve_numeric_checked(const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, const SolveOptions &opts)
方程求解选项,控制数值求解行为和结果形式.
一元多项式模板类 Polynomial<T>,支持四则运算,GCD,求导,求值.
精确有理数 Rational,基于 BigInt 分子/分母表示,自动约分。
方程求解策略调度器 solve_dispatch 及相关选项结构体.
符号表达式主类 SymbolicExpr 及其工厂方法,运算接口.