Show dynamic value as a number

  • Mathematica
  • Thread starter Swamp Thing
  • Start date
  • Tags
    Dynamic Value
In summary, if you want y to be displayed as a plain numeric value just as z is displayed, you will need to feed it through the N[] function.
  • #1
Swamp Thing
Insights Author
908
572
TL;DR Summary
How to force expressions containing dynamic variables to display as numeric values?
In the example below, x is static while x1 is a dynamic copy of x. Also, y and z are similar expressions containing x and x1 respectively.
If we evaluate expressions containing x and x1, they display in numeric and mathematical formats, respectively (y and z below). How can I display z as a plain numeric value just as y is displayed?
dynamic.png
 
Physics news on Phys.org
  • #2
That is weird. Why is y displayed like that? It should be displayed like z.
 
  • #3
Something is wrong with your y. That value is not correct and it should not be displayed like that. However, I also cannot get it to display as a single decimal. The closest I get is

Code:
z = N[Sqrt[x1/2/Pi]]

But this gives ##0.398942 \sqrt{200}##
 
  • #4
Is it because defining x1 as dynamic that symbolic evaluation is being done?

Have you tried the eval() function on your dynamic expression?
 
  • #5
Dale said:
Something is wrong with your y.

Yes, there was. I corrected that, and now the y needs to be fed through N[] in order to see the numeric.

jedishrfu said:
Have you tried the eval() function on your dynamic expression?
Neither N[] nor Evaluate[] are helpful in the dynamic case.

dynamic.png
 
  • #7
This may explain the problem (but I'm still trying to understand it fully) :
https://reference.wolfram.com/language/tutorial/IntroductionToDynamic.html#1063215934

It seems to imply that you can't use Dynamic as an input to other functions, because it never goes to the kernel. It's just a directive for the front end.

The solution is probably to make sure that Dynamic encloses all the code that is going to use the variable that we want to make dynamic. I am experimenting along these lines.

But if we put Dynamic around a whole block of code, and if that block of code references many global variables, then it has no way to know which ones we want it to watch and respond to. All global variables would become dynamic. There must be a way to make it dynamic with respect to some selected variables and ignore changes in others?
 

1. What does it mean to "show dynamic value as a number"?

"Show dynamic value as a number" refers to the process of displaying a changing or variable value as a numerical value, rather than a static text or image.

2. Why is it important to show dynamic value as a number?

Showing dynamic values as numbers allows for easier understanding and comparison of data. It also allows for real-time updates of changing values.

3. How can I show dynamic value as a number in my project?

This can be achieved through various programming techniques, such as using variables and functions to calculate and display the dynamic value as a numerical output.

4. Can I customize the way the dynamic value is shown as a number?

Yes, you can customize the formatting of the number, such as the number of decimal places, using programming techniques or built-in functions specific to your project's programming language.

5. Are there any drawbacks to showing dynamic value as a number?

One potential drawback is that it may be more difficult for some individuals to interpret numerical data compared to visual representations. Additionally, constantly updating numerical values can make it harder to track changes over time.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
555
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
Replies
8
Views
533
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
11
Views
1K
  • Calculus and Beyond Homework Help
Replies
8
Views
475
  • Engineering and Comp Sci Homework Help
Replies
16
Views
2K
  • Precalculus Mathematics Homework Help
Replies
8
Views
424
Back
Top