Python: fit data to given cosine function
问题 I am trying to simply find best fit for malus's law. I_measured=I_0*(cos(theta)) ^2 When I scatter the plot, it obviously works but with the def form() function I get the error given below. I googled the problem and it seems that this is not the correct way to curvefit a cosine function. given data is .. x_data=x1 in the code below [ 0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, 95.0, 100.0, 105.0, 110.0, 115.0, 120.0, 125.0,