@@ -8,8 +8,8 @@ initial guesses `(left, middle, right)` for the root.
88
99### Keyword Arguments
1010
11- - `middle`: the initial guess for the middle point. If not provided, the
12- midpoint of the interval `(left, right)` is used.
11+ - `middle`: the initial guess for the middle point. If not provided, the
12+ midpoint of the interval `(left, right)` is used.
1313"""
1414struct Muller{T} <: AbstractBracketingAlgorithm
1515 middle:: T
1818Muller () = Muller (nothing )
1919
2020function CommonSolve. solve (prob:: IntervalNonlinearProblem , alg:: Muller , args... ;
21- abstol = nothing , maxiters = 1000 , kwargs... )
21+ abstol = nothing , maxiters = 1000 , kwargs... )
2222 @assert ! SciMLBase. isinplace (prob) " `Muller` only supports out-of-place problems."
2323 xᵢ₋₂, xᵢ = prob. tspan
2424 xᵢ₋₁ = isnothing (alg. middle) ? (xᵢ₋₂ + xᵢ) / 2 : alg. middle
@@ -32,35 +32,35 @@ function CommonSolve.solve(prob::IntervalNonlinearProblem, alg::Muller, args...;
3232 abstol = abs (NonlinearSolveBase. get_tolerance (
3333 xᵢ₋₂, abstol, promote_type (eltype (xᵢ₋₂), eltype (xᵢ))))
3434
35- for _ ∈ 1 : maxiters
36- q = (xᵢ - xᵢ₋₁)/ (xᵢ₋₁ - xᵢ₋₂)
37- A = q* fxᵢ - q* (1 + q)* fxᵢ₋₁ + q^ 2 * fxᵢ₋₂
38- B = (2 * q + 1 )* fxᵢ - (1 + q)^ 2 * fxᵢ₋₁ + q^ 2 * fxᵢ₋₂
39- C = (1 + q)* fxᵢ
35+ for _ in 1 : maxiters
36+ q = (xᵢ - xᵢ₋₁) / (xᵢ₋₁ - xᵢ₋₂)
37+ A = q * fxᵢ - q * (1 + q) * fxᵢ₋₁ + q^ 2 * fxᵢ₋₂
38+ B = (2 * q + 1 ) * fxᵢ - (1 + q)^ 2 * fxᵢ₋₁ + q^ 2 * fxᵢ₋₂
39+ C = (1 + q) * fxᵢ
4040
41- denom₊ = B + √ (B^ 2 - 4 * A * C)
42- denom₋ = B - √ (B^ 2 - 4 * A * C)
41+ denom₊ = B + √ (B^ 2 - 4 * A * C)
42+ denom₋ = B - √ (B^ 2 - 4 * A * C)
4343
4444 if abs (denom₊) ≥ abs (denom₋)
45- xᵢ₊₁ = xᵢ - (xᵢ - xᵢ₋₁)* 2 * C / denom₊
45+ xᵢ₊₁ = xᵢ - (xᵢ - xᵢ₋₁) * 2 * C / denom₊
4646 else
47- xᵢ₊₁ = xᵢ - (xᵢ - xᵢ₋₁)* 2 * C / denom₋
47+ xᵢ₊₁ = xᵢ - (xᵢ - xᵢ₋₁) * 2 * C / denom₋
4848 end
4949
5050 fxᵢ₊₁ = f (xᵢ₊₁)
5151
5252 # Termination Check
5353 if abstol ≥ abs (fxᵢ₊₁)
5454 return SciMLBase. build_solution (prob, alg, xᵢ₊₁, fxᵢ₊₁;
55- retcode = ReturnCode. Success,
56- left = xᵢ₊₁, right = xᵢ₊₁)
55+ retcode = ReturnCode. Success,
56+ left = xᵢ₊₁, right = xᵢ₊₁)
5757 end
5858
5959 xᵢ₋₂, xᵢ₋₁, xᵢ = xᵢ₋₁, xᵢ, xᵢ₊₁
6060 fxᵢ₋₂, fxᵢ₋₁, fxᵢ = fxᵢ₋₁, fxᵢ, fxᵢ₊₁
6161 end
6262
6363 return SciMLBase. build_solution (prob, alg, xᵢ₊₁, fxᵢ₊₁;
64- retcode = ReturnCode. MaxIters,
65- left = xᵢ₊₁, right = xᵢ₊₁)
64+ retcode = ReturnCode. MaxIters,
65+ left = xᵢ₊₁, right = xᵢ₊₁)
6666end
0 commit comments