
from scipy.optimize import minimize
import numpy as np


def main():
    guess = np.zeros(3)
    fmin = minimize(fun=cost1, x0=guess, args=(3, 20, -25), method="Nelder-Mead")
    print(np.mean(fmin["final_simplex"][0], axis=0))
    print(fmin)


def cost1(X, a=2, b=9, c=15):
    return (X[0]-a)**2 + (X[1]-b)**2 + (X[2]-c)**2


if __name__ == '__main__':
    main()