TransWikia.com

adding a point in a manipulate command

Mathematica Asked by computer891 on March 13, 2021

I am having trouble adding a point to mark the Min values of each parabola when using the Manipulate command?

Manipulate[
 Plot[x^2 - 2*(a - 2)*x + a - 2, {a, -20, 20}, 
  PlotRange -> {-200, 200}], {a, -10, 10}]

This gives me the parabolas but how do I get a vertex point visible as it moves with parameter a.

One Answer

You can use the options MeshFunctions, Mesh and MeshStyle as follows:

Manipulate[Plot[x^2 - 2*(a - 2)*x + a - 2, {x, -20, 20}, 
  ClippingStyle -> False,
  MeshFunctions -> {# &}, 
  Mesh -> {{a - 2}}, 
  MeshStyle -> Directive[PointSize[Large], Red], 
  PlotRange -> {-200, 200}], {a, -10, 10}]

enter image description here

Alternatively, you can use Epilog

Manipulate[Plot[x^2 - 2*(a - 2)*x + a - 2, {x, -20, 20}, 
  Epilog -> {PointSize[Large], Red, Point[{a - 2, -6 + 5 a - a^2}]}, 
  PlotRange -> {-200, 200}], {a, -10, 10}]

enter image description here

where I have used the results from:

Minimize[x^2 - 2*(a - 2)*x + a - 2, x]
 {-6 + 5 a - a^2, {x -> -2 + a}}

Correct answer by kglr on March 13, 2021

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