I'm trying to calculate a Fourier Cosine Series of displacement for general 4-bar mechanism. My code not working. I don't understand why. I need the result as this form

 A Cos[x] + B Cos[2x] + C Cos[4x]+..

Please help me.

Constants -> {r0, r1, r2, r3, theta0, xc, yc};
r0 = 100;
r1 = 25.3;
r2 = 64;
r3 = 75;
r4 = 70;
theta0 = 130 Degree;
xc = -64.279;
yc = 76.604;
(*Displacement calcualtion*)
a[theta1_] := 2*r0*r3*Cos[theta0]-2*r1*r3*Cos[theta1];
b[theta1_] := 2*r0*r3*Sin[theta0]-2*r1*r3*Sin[theta1];
c[theta1_] := 
t[theta1_] := 
theta3[theta1_] := 2*ArcTan[t[theta1]];
y2[theta1_] := r3*Sin[theta3[theta1]] + yc;
FourierCosSeries[y2[theta1], theta1, 10]

The problem is that the command FourierCosSeries expects a function whose cosine series expansion can be evaluated exactly - while the function y2[theta1] is far too complicated. I would suggest replacing your final line of code with the numerical equivalent

y2f[theta1_] := Evaluate[1/Pi*NIntegrate[y2[theta1], {theta1, 0, Pi}] + 
                 Sum[2/Pi*NIntegrate[y2[theta1]*Cos[k theta1], {theta1, 0, Pi}]*
                     Cos[k theta1], {k, 1, 10}]]

Plot[{y2@t1, y2f@t1}, {t1, 0, Pi}, PlotStyle -> {{Thick, Green}, {Dashed, Blue}}]

Mathematica graphics

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.