MCPcopy Index your code
hub / github.com/cfgnunes/numerical-methods-python / example_solution_pegasus

Function example_solution_pegasus

main.py:160–183  ·  view source on GitHub ↗

Run an example 'Solutions: Pegasus'.

()

Source from the content-addressed store, hash-verified

158
159@print_docstring
160def example_solution_pegasus():
161 """Run an example 'Solutions: Pegasus'."""
162
163 def f(x):
164 return 2 * x ** 3 - math.cos(x + 1) - 3
165
166 a = -1.0
167 b = 2.0
168 toler = 0.01
169 iter_max = 100
170
171 print("Inputs:")
172 print(f"a = {a}")
173 print(f"b = {b}")
174 print(f"toler = {toler}")
175 print(f"iter_max = {iter_max}")
176
177 print("Execution:")
178 root, i, converged = solutions.pegasus(f, a, b, toler, iter_max)
179
180 print("Output:")
181 print(f"root = {root:.5f}")
182 print(f"i = {i}")
183 print(f"converged = {converged}")
184
185
186@print_docstring

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected