0
$\begingroup$

I am very new to mathematica and also new to this community. I have a problem given below, How to express this in Mathematica?

$H=[2,4,10,5,12,34,42,\cdots 12]$ is a vector of size $N$. $h_n$ is the $n$th element of $H$. For example, $h_3=10$ and $h_N=12$.

$F(\theta)=h_{N/2+1}+2\sum_{l=1}^{N/2-1}h_{N/2-l}\cos (\theta l)$

I want to calculate $\int_{.234}^{432}(F(\theta))^2$

Any help will be appreciated!

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – user9660 Apr 10 '15 at 14:08
1
$\begingroup$

is this what you are looking for?

h = {2, 4, 10, 5, 12, 34, 12, 11};
n = Length[h];
f[x_?NumericQ] := h[[n/2 + 1]] + 2 NSum[ h[[n/2 - i]] Cos[x*i], {i, 1, n/2 - 1}]

NIntegrate[f[x]^2, {x, 0.234, 0.432}]

Mathematica graphics

$\endgroup$
1
$\begingroup$
h = {5, 7, 8, 15, 11, 17, 20, 20, 5, 3}; (*put your vector here*)
n = Length[h] ;(*length of the vector, Even number*)
F[x_] = h[[n/2 + 1]] + 2 Sum[h[[n/2 - l]] Cos[x l], {l, 1, n/2 - 1}];
NIntegrate[F[x]^2, {x, 0.234, 0.432}]
$\endgroup$
1
$\begingroup$
func[t_, v_] := With[{s = Length[v]/2},
  2 Total@MapIndexed[#1 Cos[First@#2 t] &, Reverse[v[[1 ;; s - 1]]]] +
    v[[s + 1]]]

Test:

h = {2, 4, 10, 5, 12, 34, 12, 11};
Integrate[func[t, h]^2, {t, 0.234, 0.432}]

yields: 305.526

Adjust as desired for non-even list length

$\endgroup$

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.