TransWikia.com

How to flip the function f(x) about y-axis

Mathematica Asked by acoustics on December 16, 2020

Suppose I have a function W(x). I wanted to flip (reflect) this function about the y-axis. I tried plotting W(-x) but it is not giving the expected results.

L = 4;
beta1 = {0.468776, 1.17352, 1.96369, 2.74889, 3.53429, 4.31969, 
  5.10509, 5.89049, 6.67588, 7.46128, 8.24668, 9.03208, 9.81748}
W = ((Cos[b*x] - 
      Cosh[b*x]) - (((Cos[b*L] + Cosh[b*L])/(Sin[b*L] + 
         Sinh[b*L]))*(Sin[b*x] - Sinh[b*x]))) /. b -> beta1[[1]]

2 Answers

W[x_] := ((Cos[b*x] - Cosh[b*x]) - (((Cos[b*L] + Cosh[b*L])/(Sin[b*L] + 
          Sinh[b*L]))*(Sin[b*x] - Sinh[b*x]))) /. b -> beta1[[1]]

plt = Plot[W[x], {x, -2 Pi, 2 Pi}]; 

1. Use the option ScalingFunctions -> {"Reverse", None}

Show[plt, 
 Plot[W[x], {x, -2 Pi, 2 Pi}, ScalingFunctions -> {"Reverse", None}, 
  PlotStyle -> Red], PlotRange -> All]

enter image description here

2. Post-process the output to transform lines:

Show[plt, plt /. Line[x_] :> {Red, Line[{-1, 1} # & /@ x]}, PlotRange -> All]

Alternatively, use ReflectionTransform:

Show[plt, 
 plt /. L_Line :> {Red, GeometricTransformation[L, ReflectionTransform[{-1, 0}]]}, 
 PlotRange -> All]

enter image description here

3. Use ParametricPlot with {-x, W[x]}} as the first argument:

ParametricPlot[{{x, W[x]}, {-x, W[x]}}, {x, -2 Pi, 2 Pi}, 
 PlotStyle -> {Automatic, Red}]

or

Show[ParametricPlot[{x, W[x]}, {x, -2 Pi, 2 Pi}], 
 ParametricPlot[{-x, W[x]}, {x, -2 Pi, 2 Pi}, PlotStyle -> Red], 
 PlotRange -> All]

enter image description here

Answered by kglr on December 16, 2020

Reply the comment

L = 4;
beta1 = {0.468776, 1.17352, 1.96369, 2.74889, 3.53429, 4.31969, 
   5.10509, 5.89049, 6.67588, 7.46128, 8.24668, 9.03208, 9.81748};
w[x_] := ((Cos[b*x] - 
      Cosh[b*x]) - (((Cos[b*L] + Cosh[b*L])/(Sin[b*L] + 
          Sinh[b*L]))*(Sin[b*x] - Sinh[b*x])));
interval = Interval[{-3, 2 Pi}];
{Plot[Table[w[x], {b, beta1}] // Evaluate, x ∈ interval],
  Plot[Table[w[-x], {b, beta1}] // Evaluate, 
   x ∈ -interval]} // GraphicsRow

enter image description here

L = 4;
beta1 = {0.468776, 1.17352, 1.96369, 2.74889, 3.53429, 4.31969, 
   5.10509, 5.89049, 6.67588, 7.46128, 8.24668, 9.03208, 9.81748};
w[x_] := ((Cos[b*x] - 
       Cosh[b*x]) - (((Cos[b*L] + Cosh[b*L])/(Sin[b*L] + 
           Sinh[b*L]))*(Sin[b*x] - Sinh[b*x]))) /. b -> beta1[[1]];
interval = Interval[{-3, 2 Pi}];
Show[Plot[w[x], x ∈ interval, PlotStyle -> Green], 
 Plot[w[-x], x ∈ -interval, PlotStyle -> Red], 
 PlotRange -> All]

enter image description here

Answered by cvgmt on December 16, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP