Differential Equations - Dynamic Models

A Theoretical Introduction to Dynamic Models

I. Dynamic

Ordinary Wolfram Language sessions consist of a series of static inputs and outputs, which form a record of calculations done in the order in which they were entered.

In[1]:   x = 5;

In[2]:   x2

Out[2]: 25

However, you may often want a fundamentally different kind of output, one that is automatically updated to always reflect its current value. This new kind of output is provided by Dynamic.

Evaluate the following cell; note that the result will be again 25 because the current value of x is 5:

In[1]:  Dynamic[x2]

Out[1]: 25

But if you subsequently change the value of the variables, the displayed output will change retroactively.

In[2]:   x = 7;

Note that Out[1] automatically changed to 49.

Practice with different dynamic objects in the following notebook:

DynamicModules1 Wolfram Technology at Howard University | Howard University ...

II. Sliders

This associates the position of the slider with the current value of the variable x. 

In[16]:  Slider[Dynamic[x]]   

In[17]: Dynamic[x]

Out[17]:  0.15

Drag the slider around. As the slider moves, the value of x changes and the dynamic output updates in real time.

The great power of Dynamic lies in the fact that it can display any function of x just as easily.

Dynamic graph with slider controlled frequency:

       

Dynamic binomial expansion with slider controlled exponent:

    

This changes the disk color:

In[63]:=  Clear[ red ];
              Slider [Dynamic[red] ]
              Graphics[ {RGBColor[Dynamic[red], 0.5, 0.5], Disk[ ] }]

Out[63]:=

      

*** Make three sliders with red, green, blue variables to control all components of RGB color directive.

Practice with different sliders in the following notebook:

DynamicModules2 Wolfram Technology at Howard University | Howard University ...