-1
$\begingroup$

I've written this source code, but I can't finish it yet.

Manipulate[
 Show[Plot[a Abs[x - h] + k, {x, -10, 10}], 
  PlotRange -> {{-10, 10}, {-10, 10}}, AxesOrigin -> {0, 0}, 
  AspectRatio -> 1, ImageSize -> {500, 400}
 ],
 {{a, 1, Style["a", Italic]}, -5, 5, .01, Appearance -> "Labeled"},
 {{h, 0, Style["h", Italic]}, -5, 5, .01, Appearance -> "Labeled"},
 {{k, 0, Style["k", Italic]}, -5, 5, .01, Appearance -> "Labeled"}
]
$\endgroup$
  • 4
    $\begingroup$ I think you'll need to explain your question better. The code seems to plot graphs of various absolute value functions. But I don't see any inequalities here, or anything that needs to be solved. Can you elaborate? $\endgroup$ – C. Woods Feb 22 '16 at 15:22
0
$\begingroup$
Manipulate[
 Column[{
   Plot[a Abs[x - h] + k, {x, -10, 10},
    PlotRange -> {{-10, 10}, {-10, 10}},
    AxesOrigin -> {0, 0},
    AspectRatio -> 1,
    ImageSize -> {500, 400},
    AxesLabel -> (Style[#, 14, Bold] & /@ {"x", "y"}),
    Epilog -> {Red, AbsolutePointSize[6],
      Point[{h, k}]}],
   StringForm["\nx = ``, y = ``",
    NumberForm[h, {3, 2}], NumberForm[k, {3, 2}]]},
  Alignment -> Center],
 {{a, 1, Style["a", Italic]}, -5, 5, .01,
  Appearance -> "Labeled"},
 {{h, 0, Style["h", Italic]}, -5, 5, .01,
  Appearance -> "Labeled"},
 {{k, 0, Style["k", Italic]}, -5, 5, .01,
  Appearance -> "Labeled"}]

enter image description here

EDIT: Note that in the Solve, Abs[a x + b] is replaced by the equivalent (for real-valued functions) Sqrt[(a x + b)^2]

Manipulate[
 pts = {x, e x + f} /. Solve[Sqrt[(a x + b)^2] + c x + d == e x + f, x];
 Column[{
   Plot[{Abs[a x + b] + c x + d, e x + f},
    {x, -10, 10},
    Epilog -> {Red, AbsolutePointSize[5],
      Point[pts]},
    ImageSize -> 360,
    PlotLegends ->
     Placed[
      {Abs[a x + b] + c x + d, e x + f},
      Below]],
   StringForm["Intercepts = ``",
    NumberForm[pts // N, {4, 2}]]},
  Alignment -> Center],
 {{a, 2, Style["a", Italic]},
  -5, 5, .01, Appearance -> "Labeled"},
 {{b, 0, Style["b", Italic]},
  -5, 5, .01, Appearance -> "Labeled"},
 {{c, 0, Style["c", Italic]},
  -5, 5, .01, Appearance -> "Labeled"},
 {{d, -3, Style["d", Italic]},
  -5, 5, .01, Appearance -> "Labeled"},
 {{e, 0, Style["e", Italic]},
  -5, 5, .01, Appearance -> "Labeled"},
 {{f, 5, Style["f", Italic]},
  -5, 5, .01, Appearance -> "Labeled"}]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you very much Bob, you helped me a lot.:) I'm just thinking about how can I complete your code, if I want to model abs(ax+b)+(cx+d)=ex+f. $\endgroup$ – Zauberkerl Feb 22 '16 at 19:38
  • $\begingroup$ @Zauberkerl - see edit above. $\endgroup$ – Bob Hanlon Feb 25 '16 at 2:05
-1
$\begingroup$

Try this:

Manipulate[
 Plot[a Abs[x - h] + k, {x, -10, 10}, 
   PlotRange -> {{-10, 10}, {-10, 10}}, AxesOrigin -> {0, 0}, 
   AspectRatio -> 1, ImageSize -> {500, 400}
 ],
 {{a, 1, Style["a", Italic]}, -5, 5, .01, Appearance -> "Labeled"}, 
 {{h, 0, Style["h", Italic]}, -5, 5, .01, Appearance -> "Labeled"}, 
 {{k, 0, Style["k", Italic]}, -5, 5, .01, Appearance -> "Labeled"}
]

enter image description here

Have fun!

| improve this answer | |
$\endgroup$
  • 2
    $\begingroup$ Alexei, correct me if I'm wrong, but all you've done is removed the redundant Show from the OP's code. Your code achieves the same result as the OP's though. Perhaps this should be a comment rather than an answer, or you may want to state explicitly what changes you have made to the code. $\endgroup$ – MarcoB Feb 22 '16 at 15:43
  • $\begingroup$ @MarcoB You are right. All I wrote: "Try this" $\endgroup$ – Alexei Boulbitch Feb 23 '16 at 13:14

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.