Spreadsheet workshop

Main web page - overview of spreadsheet workshop
	simple fundamentals of rows and columns
		constants and their labels
		copying formulas down a column
	simple fundamentals of graphs
		selecting a group of cells to graph
		graph wizard
		changing the graph scale
	sliders
	how to insert
	use a slider to change a graph:  wavelength
	numerical integration via RK2
		calculate derivatives at the half-step
		columns for functions at full step and half-step
		examples
			falling w/ air resistance
			pendulum w and w/o air resistance
			1-d acoustics ss w/ slider
	
Connect graphical and analytical techniques

Numerical integration
Animation
Sliders for graphical feedback
Solver for nonlinear equations
Ray diagrams
Executing basic code underneath a spreadsheet
	How complex?  Not very. A few symbols

How-To Simple Instructions:  View -> Control Toolbox   ->Visual Basic

•	Using sliders

•	Using Visual Basic
•		Put up a Label
•		Put up a 2-item button control
•		Execute some basic code when the button is pressed
•		This button clears the array A10..A20
•		This button increments the array A10..A20
•		This button doubles the array A10..A20

Private Sub PutScreenDistribution()
' put the master distribution on the screen
    Dim i As Integer
    Dim st As String
    For i = 0 To Nl        ' Put in B3 to B23
        st = "B" & Format(i + 3)
        Range(st).Select
        ActiveCell.Value = master(i)
    Next i
End Sub

Private Sub GetScreenDistribution()
' put the screen distribution into the master distribution
    Dim i As Integer
    Dim st As String
    For i = 0 To Nl
        st = "B" & Format(i + 3)
        Range(st).Select
        master(i) = ActiveCell.Value
    Next i
End Sub

start of code 

Option Explicit
Const Nd = 10 ' number of distributions
Const Nl = 20 ' number of energy levels (starting at zero)
Dim distrib(Nd + 5, Nl) As Integer
' the row (first) index is for the number of the trial distribution
' the column (second) index is for the energy level (0 .. Nl)
Dim master(Nl) ' the master distribution with max entropy
Dim S(Nd) As Double ' array of entropy values
Dim Smax As Double
Dim Scurr As Double
Dim Sprev As Double
Dim Ntotal As Double

Private Sub Drop(DistNr As Integer)
' drop two from one level and add one to each neighbor
' make sure the level has at least 2 units in it
' try it 50 times or until one is found
    Dim j As Integer
    Dim k As Integer
    Dim NotFound As Boolean
    Dim En As Double
    NotFound = True
    
    ' Try to shift with neighboring levels
    k = 0
    Do While k < Nl - 1 And NotFound
        For j = 0 To Nl
        distrib(Nd + 1, j) = distrib(DistNr, j)
        Next j
        ' k is an energy level in range 1 to Nl-1
        k = k + 1
        distrib(Nd + 1, k) = distrib(Nd + 1, k) - 2
        distrib(Nd + 1, k - 1) = distrib(Nd + 1, k - 1) + 1
        distrib(Nd + 1, k + 1) = distrib(Nd + 1, k + 1) + 1
        En = Entropy(Nd + 1)
        If En > Smax Then
            NotFound = False
            S(DistNr) = En
            For j = 0 To Nl
                distrib(DistNr, j) = distrib(Nd + 1, j)
            Next j
        End If
    Loop
    ' Try to shift with next-neighboring levels
    k = 1
    Do While k < Nl - 2 And NotFound
        k = k + 1
        For j = 0 To Nl
        distrib(Nd + 1, j) = distrib(DistNr, j)
        Next j
        ' k is an energy level in range 2 to Nl-2
        distrib(Nd + 1, k) = distrib(Nd + 1, k) - 2
        distrib(Nd + 1, k - 2) = distrib(Nd + 1, k - 2) + 1
        distrib(Nd + 1, k + 2) = distrib(Nd + 1, k + 2) + 1
        En = Entropy(Nd + 1)
        If En > Smax Then
            NotFound = False
            S(DistNr) = En
            For j = 0 To Nl
                distrib(DistNr, j) = distrib(Nd + 1, j)
            Next j
        End If
    Loop
    If NotFound Then
        S(DistNr) = Entropy(DistNr)
    End If
    
End Sub