0
$\begingroup$

I want to show the numerical results of (universal) gravitation.

However, how to give the value in the control bar?

G = 6.67259*10^(-11);
Manipulate[
   Show[Plot[G*(M*m)/R^2, {R, 0, 1}, 
   PlotRange -> {{0, 1.2}, {0, 2*10^(-8)}}], 
   Graphics[{Red, PointSize[Large], Point[{r, G*(M*m)/r^2}]}]], {
    {M, 5}, 1, 10, Appearance -> "Labeled"}, {{m, 1}, 1, 10, 
    Appearance -> "Labeled"}, {{r, 0.3}, 0.1, 1, 
    Appearance -> "Labeled"}, Text@Style["F=", Black], 
    TrackedSymbols :> {M, m, r}]
$\endgroup$

1 Answer 1

1
$\begingroup$
Clear["Global`*"]

G = 6.67259*10^(-11);

Manipulate[
 F = G*(M*m)/r^2;
 Show[Plot[G*(M*m)/R^2, {R, 0, 1},
   PlotRange -> {{0, 1.2}, {0, 2*10^(-8)}}],
  Graphics[{Red, PointSize[Large],
    Tooltip[Point[#], #] &[{r, G*(M*m)/r^2}]}]],
 {{M, 5}, 1, 10, 0.1, Appearance -> "Labeled"},
 {{m, 1}, 1, 10, 0.01, Appearance -> "Labeled"},
 {{r, 0.3}, 0.1, 1, 0.01, Appearance -> "Labeled"},
 Text@Style[StringForm["F = ``", Dynamic[F]], Black],
 TrackedSymbols :> {M, m, r}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks! How to add physical units? Such as 0.3(metre) 1(kg) 3.7×10^-9(N) $\endgroup$
    – D.Matthew
    Commented May 2, 2021 at 15:49
  • $\begingroup$ Use Quantity. If after reading and applying the documentation you have issues, post a new question with the details. The use of quantities has nothing to do with the original issue of this post. $\endgroup$
    – Bob Hanlon
    Commented May 2, 2021 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.