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.

Curvefit in javascript is a simple 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 choose a linear, exponential or a power law fit.

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, v2. A Bernoulli factor of lift/drag is also included. The calculation using v2 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.

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.

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 nf0 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.

Siegel's Home Page

Physics Department| College of Science