I am trying to evaluate the following infinite series in MATLAB :
$$\hat{c_{k}}(x) = \sum_{m=0}^{\infty} a^{m} cos(2^{m+1}k \pi x)$$
For this I have written the following code:
function func = cosfun_hat(a,k)
syms m x;
assume(m,'integer');
assumeAlso(m > 0);
sum(x) = symsum(a^m*cos(k*sym(pi)*x*2^m+1),m,0,Inf);
func(x) = sum(x);
end
Now to evaluate this returned function at some input say x = 2, I write in the command window
%In the command window
func = cosfun_hat(0.5,2);
func(2)
which returns the following symbolic expression
(2^(1/2)*3^(1/2)*sum((1/2)^m*(exp(- pi*exp(m*log(2))*4*k - k)/2 + exp(pi*exp(m*log(2))*4*k + k)/2), m == 0..Inf))/2
I tried using subs to evaluate the expression,
%In the command window
syms y;
w(y) = func(y);
y = 2;
subs(w);
But it returns the same symbolic expression.
I want to be able to get the numerical value of the expression st some input x.
Thanks!
I figured out a way to do it without symbolic MATLAB.
The sum converges in under 100 iterations.
Now in command window I write,
I get the following plot: Infinite Cosine Sum
which possesses the nowhere differentiable properties.