1
$\begingroup$

I'm reading the CDF file from Making Formulas… for Everything in the WolframAlpha blog. I am confused by what's happening with In[9] and In[10].

Can anyone tell me what these two functions mean, or point out a book or documentation that I should read for reference? The expression in fourierCoefficientLineSegment looks quite different from the definition of fourier-series.

fourierCoefficientLineSegment[cs_, n_, {{t1_, x1_}, {t2_, x2_}}] := 
   With[{a = -(t2 x1 - t1 x2)/(t1 - t2), b = -(x2 - x1)/(t1 - t2)},
     If[cs === Cos, 
    If[n == 0, (t2 - t1) (2 a + b (t1 + t2))/2, 
       (-(n (a + b t1) Sin[n t1]) + n*(a + b*t2)*Sin[n*t2] - 
       b Cos[n t1] + b Cos[n t2])/n^2], 
    If[n == 0, 0, 
        (n (a + b t1) Cos[n t1] - n (a + b t2)*Cos[n t2] + 
       b (Sin[n t2] - Sin[n t1]))/n^2]]]

fourierSeriesLine[l_, n_, t_] := 
 Module[{ls, L, ts, xs, ys, Xs, Ys }, 
  ls = EuclideanDistance @@@ Partition[l, 2, 1];
  L = Total[ls];
  ts = 1. Prepend[Accumulate[ls], 0]/L 2 Pi - Pi;
  {xs, ys} = Transpose[l]; 
  {Xs, Ys} = Partition[Transpose[{ts, #}], 2, 1] & /@ {xs, ys}; 
  (Total[fourierCoefficientLineSegment[Cos, 0, #] & /@ #]/2 +
       Sum[
            Total[fourierCoefficientLineSegment[Cos, k, #] & /@ #] Cos[
          k t], {k, n}] +
       Sum[
        Total[fourierCoefficientLineSegment[Sin, k, #] & /@ #] Sin[
          k t], {k, n}])/Pi & /@ {Xs, Ys}]
$\endgroup$
2
  • $\begingroup$ I didn't see an In[9] on that page? It skips from In[8] to In[11] I believe? $\endgroup$
    – user1722
    Commented Oct 30, 2014 at 14:50
  • $\begingroup$ @barrycarter, Download the .CDF file and open it, you'll see In[9] &In[10]. $\endgroup$
    – xibinke
    Commented Oct 30, 2014 at 14:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.