1
$\begingroup$

I have a function f, the value of the function at x=0 is zero and at x=2 it is one. I am trying to interchange this, meaning at x=0, f should take the value of one and at x=2 f should be zero. Essentially I am trying to reflect my function. I am trying this. y=f(-x) to reflect about y-axis. What is the appropriate sign change I have to do to achieve this?

f = Sin[(((2*0 + 1)*π*(-x))/(2*2))];
Plot[f, {x, 0, 2}]  
$\endgroup$
  • $\begingroup$ So, Cos[Pi*x/4]? $\endgroup$ – march Feb 11 at 16:43
  • $\begingroup$ humm. May be I am missing something. Why would at x=2 f should be zero when f(-x)? Do you want to reflect across y-axis ? f(-x) reflect around y-axis. Not x-axis. So I deleted my answer, because I am confused what you are asking now. $\endgroup$ – Nasser Feb 11 at 16:49
  • $\begingroup$ I wanted to reflect about y -axis $\endgroup$ – acoustics Feb 11 at 16:53
  • $\begingroup$ @Nasser Actually the answer that you suggest works for me . $\endgroup$ – acoustics Feb 11 at 16:54
  • $\begingroup$ Ok. I undeleted my answer. I just wanted to make sure. $\endgroup$ – Nasser Feb 11 at 16:54
3
$\begingroup$

y=f(-x) to reflect about y-axis

It would be better to make your f a function, something like

f[x_] := Sin[(((2*0 + 1)* Pi *(-x))/(2*2))];
Plot[{f[x], f[-x]}, {x, -2, 2}]

ps. why do you have 2*0 in there?

Mathematica graphics

To answer comment:

ClearAll[f, x];
f[x_] := Table[Sin[(((2*i + 1)*Pi*(-x))/(2*2))], {i, 0, 2}];
p1 = Plot[Evaluate@f[x], {x, -2, 2}, PlotLabel -> "f(x)", ImageSize -> 400];
p2 = Plot[Evaluate@f[-x], {x, -2, 2}, PlotLabel -> "f(-x)", ImageSize -> 400];
Grid[{{p1, p2}}, Frame -> All]

Mathematica graphics

$\endgroup$
  • $\begingroup$ f[x_] := Table[Sin[(((2*i + 1)*Pi*(-x))/(2*2))], {i, 0, 2}]; Actually I wanted to generate multiple like this, How to do this, using table function $\endgroup$ – acoustics Feb 11 at 16:59
  • $\begingroup$ @acoustics I've added for table. $\endgroup$ – Nasser Feb 11 at 17:05

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.