I am using a slider to assign the value for a dynamic variable x, and want to display the value of y=10^Dynamic@x in decimal form. However, y, N[y], or NumberForm[y,1] all display the output as 10^0 rather than 1 (for $y=0$, for example).

How do I force the output of $y$ to display in decimal form (in Mathematica 10.3)?

I understand M11.2 has the function DecimalForm[ ], which may or may not work with dynamic variables.

Here is the code:

y = 10^Dynamic@x; {Slider[Dynamic[x], {-1, 1}], y}
  • 1
    $\begingroup$ {Slider[Dynamic[x], {-1, 1}], Dynamic[y = 10^x]} ? $\endgroup$ – ilian Jun 22 '18 at 2:26
  • $\begingroup$ @ilian Thanks. So Mathematica only evaluates the whole expression within the Dynamic function. I can then continue using the variable $y$ via Dynamic@y $\endgroup$ – Sven Jun 22 '18 at 4:55
  • $\begingroup$ Is ClearAll[x, y]; y = 10^x; {Slider[Dynamic[x], {-1, 1}], Dynamic[y]} what you are looking for? $\endgroup$ – Edmund Jun 23 '18 at 4:30
  • $\begingroup$ @Edmund Yes, indeed! Thks. $\endgroup$ – Sven Jun 24 '18 at 4:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.