Run an example 'Solutions: Muller'.
()
| 185 | |
| 186 | @print_docstring |
| 187 | def example_solution_muller(): |
| 188 | """Run an example 'Solutions: Muller'.""" |
| 189 | |
| 190 | def f(x): |
| 191 | return 2 * x ** 3 - math.cos(x + 1) - 3 |
| 192 | |
| 193 | a = -1.0 |
| 194 | b = 2.0 |
| 195 | toler = 0.01 |
| 196 | iter_max = 100 |
| 197 | |
| 198 | print("Inputs:") |
| 199 | print(f"a = {a}") |
| 200 | print(f"b = {b}") |
| 201 | print(f"toler = {toler}") |
| 202 | print(f"iter_max = {iter_max}") |
| 203 | |
| 204 | print("Execution:") |
| 205 | root, i, converged = solutions.muller(f, a, b, toler, iter_max) |
| 206 | |
| 207 | print("Output:") |
| 208 | print(f"root = {root:.5f}") |
| 209 | print(f"i = {i}") |
| 210 | print(f"converged = {converged}") |
| 211 | |
| 212 | |
| 213 | @print_docstring |