0

enter image description here

Hello. I am trying to graph the different approximations of the function $f(x)=|x|$ by convolutions with the standard Mollifier function. However, my code doesn't output the correct graph. What is wrong in the code? (This question is motivated by a topic I made Application of Mollifier function.)

Actualization 1: I tried the following code in Scilab but it doesn't work. error appears. Attached image.

x = -1:0.1:1;
f = (x > -1 & x < 1).*abs(x)+(x <= -1 | x >= 1).*0;
phi = (x > -1 & x < 1).*(exp(1/(x.^2-1))/sqrt(2*%pi))+(x <= -1 | x >= 1).*0;
y = conv(f, phi, 'same') * 0.1;
plot(x, f, 'b', x, y, 'r');
legend('f(x)', 'Convolution f * phi');

enter image description here

eraldcoil
  • 3,508
  • 1
    I think the problem is that your function is not big enough. You are now kind-of taking the convolution of $f(x)=\begin{cases}|x|&-1<x<1\0&\text{else}\end{cases}$ instead of $|x|$. Try taking the range of $x$ to be at least "width of mollifier" bigger than the part you want to plot – student91 Feb 10 '23 at 22:13
  • I tried and couldn't. I will put the code of which gives me error. – eraldcoil Feb 10 '23 at 22:59

0 Answers0