# Explain how the minimum of a scalar function can be found in SciPy using Python?

PythonServer Side ProgrammingProgramming

Finding the minimum of a scalar function is an optimization problem. Optimization problems help improve the quality of the solution, thereby yielding better results with higher performances. Optimization problems are also used for curve fitting, root fitting, and so on.

Let us see an example −

## Example

import matplotlib.pyplot as plt
from scipy import optimize
import numpy as np
print("The function is defined")
def my_func(a):
return a*2 + 20 * np.sin(a)
plt.plot(a, my_func(a))
print("Plotting the graph")
plt.show()
print(optimize.fmin_bfgs(my_func, 0))

## Output

Optimization terminated successfully.
Current function value: -23.241676
Iterations: 4
Function evaluations: 18
[-1.67096375]