Java Script Codes

Below are some javascipt codes that I have written for use in our classes. Feel free to copy the source code and modify them to your needs. Let me know of any improvements you make so I can improve the ones listed here.

**Linefit** in javascript is a simple linear
fitting program. There is space for 14 entries. Type the x and y values in the chart
and check which data points you want to include in the fit. A nice improvement on this
linear fitting program is **LineFit7** by
Alexey Kovalev from Tallahassee Community College. The R^{2} is calculated and
the graph includes grid lines and labels.

**Curvefit** in javascript is a curve
fitting program. There is space for 14 entries. Type the x and y values in the chart
and check which data points you want to include in the fit. You can also input the uncertainties
in y and check the box if you want to include them in the fit. You can choose a linear, exponential
or a power law fit. Click first the linear regression fit for initial fit values. Then click
the chi-sq search button for 10 iterations of a chi-square fit. Keep clicking the chi-square fit button till
the chi/df value stops decreasing. Note: if the chi-square fit does not converge properly, use the program
**Curvefitchi2**, which uses a grid search to find
the chi-sq minimum. It is slower, but more reliable

**Projectile Motion** in javascript is a program that
calculates and plots the motion of a projectile near the earth's surface. It is particularly
well suited to describe a fly ball in baseball. The calculation is done without air friction,
with air friction proportional to speed v, and with air friction proportional to speed squared,
v^{2}.
A Bernoulli factor of lift/drag is also included. The calculation using v^{2} air friction
describes very well all the home run data from the 2015 post season
Home Run Data base using
a terminal speed of 82 mph and a lift/drag factor of 0.56.

**Home Run Calculator** in javascript is a program
that allows the calculation of the terminal speed and lift/drag factor for a major league
home run. The data to use in the program can be found at MLB statcast
Home Run Data base.

**Catenary Arch** in javascript is a program
that assists the user in building a catenary arch out of wood. The user can choose up to
15 wooden blocks, and input the horizontal position of the blocks as well as the shape
(scale) factor "a" for the catenary. The program outputs the block lengths and the cutting angles
for the ends of each block.

**Sudokusolver9** is a javascript program that
finds the solution of a 9 by 9 Sudoku puzzle. The program was written by Jonathan Siegel, and
can be modified to solve any Sudoku puzzle with square inner sections.

**Sudokusolver6** is a javascript program that
finds the solution of a 6 by 6 Sudoku puzzle with 3 by 2 inner sections. The program is a modified
version of Sudokusolver9 for a 6 by 6 puzzle with 3 by 2 inner sections. The program can be
modified to solve any Sudoku puzzle with rectangular inner sections..

**Damped Driven Oscillator** in javascript is a program
that calculates the motion of a damped driven simple harmonic oscillator. The program displays position versus time,
and velocity versus position.

**Damped Driven Pendulum (Euler)** and
**Damped Driven Pendulum (Runge-Kutta 2)**
are javascript programs
that calculate the motion of a damped driven pendulum. The program displays angle versus time,
angular velocity versus angle, and a Poincare plot. Two algorithms are given to demonstrate the
difficulty in solving non-linear systems numerically. For two articles on the damped driven
pendulum experiment see
**Transient Motion** and
**Strange Attractor**.

**Damped Driven Pendulum Simulation (Euler)** and
**Damped Driven Pendulum Simulation (Runge-Kutta 2)**
are javascript programs
that calculate the motion of a damped driven pendulum. The program displays angle versus time,
angular velocity versus angle, and a Poincare plot. It is similar to the program above, except that
the air friction is proportional to the velocity squared, and the driving force
is perpendicular to the restoring force. Two algorithms are given to demonstrate the difficulty
in solving non-linear systems numerically.

**Heizkennlinie Calculator** in javascript that
allows the user to determine the Vorlauftemperatur for a heat pump.

**Inverse Square Analyzer** in javascript is a simple
code to be used in our Radiation Lab to investigate the inverse square law.

**Binary to Decimal** is a simple javascript
program that changes binary numbers of less than 12 bits to the corresponding decimal
number. It is useful to use with our binary Geiger Counters to change the
number of counts to decimal.

**RPN Calculator** in javascript is a simple
Reverse Polish Notation calculator.

**Photon Entanglement** in javascript is used to
determine the amount of entanglement of the down converted photons in our experiment with
the BBO crystal.

**mcafit2** is a Gaussian curve fitting program for
gamma spectroscopy. The spectrometer has 1000 channels. To check it out, download the file:
cs137.Chn or
co60.Chn to your local hard disk. Then, run the
javascript program and upload one of the *.Chn data files.

**chn2txt** is a program that will convert 1000 channel *.chn
files to a text file.

**gefit8** is a Gaussian curve fitting program for
high resolution gamma spectroscopy. The spectrometer has 8000 channels. To check it out, download the file:
norco.cnf to your local hard disk. Then, run the
javascript program and upload the norco file.

**gefit6** is a Gaussian curve fitting program for
high resolution gamma spectroscopy. The difference between this code and gefit8 is that
the double peak fit uses width values determined from the channel number. There are only
6 free parameters.

**naisoilfit2** is a Gaussian curve fitting program
for the NaI detector designed for analyzing soil samples. The only difference between this program
and mcafit2 is the background function that is used.

**disksources** is a program that we use to determine
the exponent for the power law relationship between counts/yield and Energy for the sources
Bi^{207}, Na^{22}, and Co^{60}.

**cnf2txt** is a program that will convert 8000 channel *.cnf
files to a text file.

**soilfit** is a program that we use in
our Radiation Physics lab to analyse environmental samples. The user enters the
counts/yield for the energies of the two decay series of interest. The code
finds the best fit using the same exponent for each decay series.

**ooptics6** is a Gaussian curve fitting program for
the Ocean Optics optical spectroscopy. To check it out, download the file:
oohydrogen.txt to your local hard disk. Then, run the
javascript program and upload the hydrogen file.

**Valance Nucleon Levels** is
a program that calculates the energy levels for a valance nucleon.

**Valance Electron Levels** is
a program that calculates the energy levels for a valance electron.

**Valance Electron levels II**
is a program that calculates the atomic levels a valance electron with
Z protons and n screening electrons. The program was written by
Christos Gandara as part of his senior project.

**Mortgage Calculator** is
a program that calculates the monthly mortgage for a loan. Click
on one of the three buttons (Amount, Years, or Payment) to find
its value for the other variables being fixed.

**sinplot** is a program that
adds sin waves. You can add sin waves of frequencies nf_{0} for
values of n from 1 to 6. For each frequency you can vary the amplitude
of the sin wave. The program is designed to show how one can construct
any periodic function by adding appropriate sin waves (i.e. Fourier
analysis).

**fourier1** is a program that
does a fourier analysis of a period sound wave. You can upload a
*.wav file from your computer, that is saved in either 8 bit, 16 bit
(ideal), or 32 bit format. The program assumes a collection rate of
22050 samples/sec in determing the frequency. Move the cursors to
the start and end of the analysis interval and set the number of
cycles in the interval. Hit the fourier analysis button and the
results will be listed and graphed.

**musicnotes** (work in progress)

**sum2sin** (work in progress)

**German-English flash cards**
is a program to help improve one's german(english) vocabulary. Copy the
source code and the gedict.js file to your computer and add your own
vocabulary words.

**Linear Interpolator** is a
program to do linear interpolation of two values.

**Michaelis-Menten Fit** is a
program to fit data to the Michaelis-Menten formula.

There is a translation of this page the Czech language. All links to translations have been removed.