0

I'm trying to verify Malus' Law I = I_0 * cos^2(x) by fitting a function to data obtained during an experiment. The method I've been using does give me a realistic value for I_0, but not for the exponent. The function it gives me, does not look like a cosine at all.

My datafile looks like this:

0           825   
0.261799    735    
0.523599    678.2   
0.785398    583    
1.047198    405    
1.308997    154    
1.570796    3.2     
1.832596    154
2.094395    405
2.356194    583
2.617994    678.2
2.879793    735
3.141593    825
3.403393    735
3.665191    678.2
3.926991    583
4.188790    405
4.450590    154
4.712389    3.2
4.974188    154
5.235988    405
5.497787    583
5.759586    678.2
6.021386    735
6.283185    825

I've been trying to use fit a*cos(x)**b 'data_malus.txt' via a,b. Which gives me this: 829.217*cos(x)**145.994

1 Answers1

1

When cos(x) is negative and with b not integer then cos(x)**b is not real but complex. I suppose that you want to fit a real function with real parameters. Thus you must not write a * cos(x)**b but write a * ((cos(x) ** 2) ** (b/2)) or equivalently a * abs(cos(x))**b.

enter image description here

JJacquelin
  • 1,529
  • 1
  • 9
  • 11