@@ -125,8 +125,11 @@ class Calculator {
125125 /// (NFV) of zero.
126126 ///
127127 /// [convention] The day count convention to use (e.g., [US30360] , [USAppendixJ] ).
128- /// [guess] Initial guess for the interest rate. Defaults to 0.1 (10%).
128+ ///
129129 /// [upperBound] Upper limit for the search. Defaults to 10.0 (1000%).
130+ ///
131+ /// [tolerance] Minimum precision required from the returned root.
132+ ///
130133 /// [startDate] Optional start date for undated series. Defaults to today if null.
131134 ///
132135 /// Returns the annualized effective interest rate, unrounded.
@@ -143,8 +146,8 @@ class Calculator {
143146 /// (periodic rate × [DayCountTimePeriod.periodsInYear] ).
144147 Future <double > solveRate ({
145148 required Convention convention,
146- double guess = 0.1 ,
147149 double upperBound = 10.0 ,
150+ double tolerance = 1e-8 ,
148151 DateTime ? startDate,
149152 }) async {
150153 if (_series.isEmpty) {
@@ -167,7 +170,12 @@ class Calculator {
167170 nfv (profiled: profile, rate: r, convention: convention);
168171
169172 try {
170- double result = brentSolve (f: nfvFunc, a: - 0.999 , b: upperBound);
173+ double result = brentSolve (
174+ f: nfvFunc,
175+ a: - 0.999 ,
176+ b: upperBound,
177+ tolerance: tolerance,
178+ );
171179
172180 // Convert back to *annual rate*, except for days
173181 if (convention is USAppendixJ &&
@@ -187,6 +195,8 @@ class Calculator {
187195 ///
188196 /// [interestRate] The known annualized effective interest rate (e.g., 0.12 for 12%).
189197 ///
198+ /// [tolerance] Minimum precision required from the returned root.
199+ ///
190200 /// [startDate] for constructing the cash flow profile for `undated` series.
191201 /// Defaults to the current system date if `null` .
192202 ///
@@ -208,6 +218,7 @@ class Calculator {
208218 Future <double > solveValue ({
209219 required Convention convention,
210220 required double interestRate,
221+ double tolerance = 1e-8 ,
211222 DateTime ? startDate,
212223 }) async {
213224 if (_series.isEmpty) {
@@ -244,7 +255,7 @@ class Calculator {
244255 f: nfvFunc,
245256 a: - 1e10 ,
246257 b: 1e10 ,
247- tolerance: 1e-10 ,
258+ tolerance: tolerance ,
248259 );
249260
250261 // Return the amount for a single unknown with weighting = 1.0
0 commit comments