@@ -71,29 +71,29 @@ differentiate the function based on the input types. However, this function has
7171` xx = [1.0, 2.0, 3.0, 4.0] ` followed by a ` xx[1] = var[1] - v_true[1] ` where ` var ` might
7272be a Dual number. This causes the error. To fix it:
7373
74- 1 . Specify the ` autodiff ` to be ` AutoFiniteDiff `
74+ 1 . Specify the ` autodiff ` to be ` AutoFiniteDiff `
7575
76- ``` @example dual_error_faq
77- sol = solve(prob_oop, LevenbergMarquardt(; autodiff = AutoFiniteDiff());
78- maxiters = 10000, abstol = 1e-8)
79- ```
76+ ``` @example dual_error_faq
77+ sol = solve(prob_oop, LevenbergMarquardt(; autodiff = AutoFiniteDiff());
78+ maxiters = 10000, abstol = 1e-8)
79+ ```
8080
81- This worked but, Finite Differencing is not the recommended approach in any scenario.
81+ This worked but, Finite Differencing is not the recommended approach in any scenario.
8282
83- 2 . Rewrite the function to use
84- [ PreallocationTools.jl] ( https://github.com/SciML/PreallocationTools.jl ) or write it as
83+ 2 . Rewrite the function to use
84+ [ PreallocationTools.jl] ( https://github.com/SciML/PreallocationTools.jl ) or write it as
8585
86- ``` @example dual_error_faq
87- function fff_correct(var, p)
88- v_true = [1.0, 0.1, 2.0, 0.5]
89- xx = eltype(var)[1.0, 2.0, 3.0, 4.0]
90- xx[1] = var[1] - v_true[1]
91- return xx - v_true
92- end
86+ ``` @example dual_error_faq
87+ function fff_correct(var, p)
88+ v_true = [1.0, 0.1, 2.0, 0.5]
89+ xx = eltype(var)[1.0, 2.0, 3.0, 4.0]
90+ xx[1] = var[1] - v_true[1]
91+ return xx - v_true
92+ end
9393
94- prob_oop = NonlinearLeastSquaresProblem{false}(fff_correct, v_init)
95- sol = solve(prob_oop, LevenbergMarquardt(); maxiters = 10000, abstol = 1e-8)
96- ```
94+ prob_oop = NonlinearLeastSquaresProblem{false}(fff_correct, v_init)
95+ sol = solve(prob_oop, LevenbergMarquardt(); maxiters = 10000, abstol = 1e-8)
96+ ```
9797
9898## I thought NonlinearSolve.jl was type-stable and fast. But it isn't, why?
9999
0 commit comments