thepage="Atomic Theory - Atomic Spectrum of Hydrogen"
//updated 11/28/00-added complete solution
//11/20/02updated netscape 7
//globals
rydberg="E(in J)=2.179*10<sup>-18</sup>(1/n<sup>2<?sup<sub>1</sub>-1/n<sup>2</sup><sub>2</sub><br>"
refnumber=
attempts=0
n1=0
n2=0
energy=0
frequency=0
wavelength=0
theanswer=0
penergy=0
tried=0
totl=0
corrt=0
type=0
given=new Array()
given[1]="n<sub>1</sub>"
given[2]="n<sub>2</sub>"
given[3]="the energy"
given[4]="the frequency"
given[5]="thewavelength"

function parts(p1,p2,p3,p4,p5,p6){
	this.p1=p1
	this.p2=p2
	this.p3=p3
	this.p4=p4
	this.p5=p5
	this.p6=p6
}
question=new Array()
ansphrase=new Array()
gansphrase=new Array()
gansphrase[1]=new parts("<br>Substitute the given values for n<sub>1</sub> and n<sub>2</sub> into the Rydberg Equation:<br>2.179*10<sup>-18</sup>*(1/","<sup>2</sup>-1/","<sup>2</sup>)=")
gansphrase[2]=new parts("<br>2.179*10<sup>-19</sup>/(2.179*10<sup>-19</sup>/","<sup>2</sup>-",")=n<sup>2</sup><br>Which, on solution, gives:","=n<sup>2</sup><br> and therefore a value of "," for n<sub>2</sub>.")
question[1]=new parts("What is the energy change in Joules which accompanies the transition of the electron in a hydrogen atoms undergoes a transition from n="," to n= ","?",1,2,3)
ansphrase[1]=new parts("<br>Substitute the given values for n<sub>1</sub> and n<sub>2</sub> into the Rydberg Equation:<br>2.179*10<sup>-18</sup>*(1/","<sup>2</sup>-1/","<sup>2</sup>)=")
question[2]=new parts("The electron in a hydrogen atoms undergoes a transition from n= "," to n= "," with the emission of a photon. What is the frequency of the photon?",1,2,4)
ansphrase[2]=new parts()
question[3]=new parts("The electron in a hydrogen atoms undergoes a transition from n="," to n= "," with the emission of a photon. What is the wavelength of the photon?",1,2,5)
ansphrase[3]=new parts("<br>Substitute the given values for n<sub>1</sub> and n<sub>2</sub> into the Rydberg Equation:<br>2.179*10<sup>-18</sup>*(1/","<sup>2</sup>-1/","<sup>2</sup>)=")
question[4]=new parts("If the electron in a hydrogen atoms is initially at principal quantum level n= "," and a photon with energy= ","Joules is absorbed, to what new quantum level is the electron promoted?",1,3,2)
ansphrase[4]=new parts("Substituting the values for n<sub>1</sub> and E gives: ")
question[5]=new parts("If the electron in a hydrogen atoms is initially at principal quantum level n= "," and a photon with frequency= ","sec<sup>-1</sup> is absorbed, to what new quantum level is the electron promoted?",1,4,2)
ansphrase[5]=new parts("The freqency is first converted into an energy. Substituting the values for n<sub>1</sub> and E gives:")
question[6]=new parts("If the electron in a hydrogen atoms is initially at principal quantum level n= "," and a photon with wavelength= ","meters is absorbed, to what new quantum level is the electron promoted?",1,5,2)
ansphrase[6]=new parts("The wavelength is first converted into an energy. Substituting the values for n<sub>1</sub> and E gives:")
question[7]=new parts("If the electron in a hydrogen atoms is initially at principal quantum level n= "," and falls to a lower level with the emission of a photon with energy= ","Joules, what is the new quantum level for the electron?",1,3,2)
ansphrase[7]=new parts("Substituting the values for n<sub>2</sub> and E gives:")
question[8]=new parts("If the electron in a hydrogen atoms is initially at principal quantum level n= "," and falls to a lower level with the emission of a photon with frequency= ","sec<sup>-1</sup>, what is the new quantum level for the electron?",1,4,2)
ansphrase[8]=new parts("The freqency is first converted into an energy. Substituting the values for n<sub>2</sub> and E gives:")
question[9]=new parts("If the electron in a hydrogen atoms is initially at principal quantum level n= "," and falls to a lower level with the emission of a photon with wavelength= ","meters, what is the new quantum level for the electron?",1,5,2)
ansphrase[9]=new parts("The wavelength is first converted into an energy. Substituting the values for n<sub>1</sub> and E gives:")
introphrase=new Array()
introphrase[1]=new parts("This problem involves the direct use of the Rydberg Equation:<br><img src='rydberg.gif'><br>In this case you are given "," and "," and are to determine the value of ",". To simplify the calculations and avoid sign confusion, we will approach all of our calculations from the view n<sub>1</sub> < n<sub>2</sub>. ")
introphrase[2]=new parts("To solve this,you must rearrange the Rydberg Equation to solve for n<sub>2</sub>:<br><img src=rydbergn2.gif><br> In this case you are beginning with a value for n<sub>1</sub> and "," of the photon.")
function startit(){
	clear()
	totl++
	document.forms[0].total.value=totl
	n1=Math.ceil(10*Math.random())
	n2=n1
	while(n2==n1)n2=Math.ceil(10*Math.random())
	diffterm=(1/(n1*n1)-1/(n2*n2))
	energy=sigfigs(2.179e-18*diffterm)
	penergy=sigfigs(Math.abs(energy))
	frequency=sigfigs(Math.abs(energy/6.626e-34))
	wavelength=sigfigs(Math.abs(3e8/frequency))
	if(Math.random()>0){buildquest(Math.ceil(3*Math.random()))}
	else{if (n1>n2){buildquest(6+Math.ceil(3*Math.random()))}
		else{buildquest(3+Math.ceil(3*Math.random()))}
	}
}
//select the question type
function buildquest(which){
	type=0
	if(which<=3)thevar=n2;
	if(which==4 || which==7)thevar=penergy;
	if(which==5 || which==8)thevar=frequency;
	if(which==6 || which==9)thevar=wavelength;
	thequest=question[which].p1+n1+question[which].p2+thevar+question[which].p3
	getanswer(which)
	showquest(thequest)
}
function cphrase(which){
	phrase=""
	if(which==1)return phrase;
	else{phrase="<br>You now must convert the energy to "
		if(which==2){
			phrase+="sec<sup>-1</sup><br>freq=E/h<br>"
			phrase+=(scinot(penergy)+"/6.626*10<sup>-34</sup>="+scinot(ans)+"sec<sup>-1</sup>")
			}
		else{
			phrase+="meters<br>freq=h/E<br>"
			phrase+=(scinot(penergy)+"/6.626*10<sup>-34</sup>="+scinot(frequency)+"sec<sup>-1</sup><br>")
			phrase+=("wavelength=3.00*10cm/sec/("+scinot(frequency)+"*100cm/meter)="+scinot(wavelength)+"meters")
			}
	return phrase
	}
}
function getanswer(which){
	if(which>3)ans=n2;
	if(which==1)ans=penergy;
	if(which==2)ans=frequency;
	if(which==3)ans=wavelength;
	buildanswer(ans,which)
}
function answer(val){
attempts++
kk=0
if(tried==2){totl++
document.forms[0].total.value=totl}
if(type==1 & n1>n2){
	if(ans>1.05*theanswer & ans<.95*theanswer){
	kk=1}}
else{if(ans<1.05*theanswer & ans>.95*theanswer){
	kk=1}}
if(kk==1){
	document.forms[0].elements[2].value="correct"
	corrt++
	document.forms[0].correct.value=corrt
	tried=1
	}
else{
	document.forms[0].elements[2].value="incorrect"
	tried=2
	}
}
function buildanswer(ans,which){
	if(which<4){
		n1>n2?nf=n2:nf=n1;
		n1>n2?ns=n1:ns=n2;
		convertphrase=cphrase(which)
		theanswer=introphrase[1].p1+given[question[which].p4]+introphrase[1].p2+given[question[which].p5]+introphrase[1].p3+given[question[which].p6]+introphrase[1].p4;
		theanswer=theanswer+gansphrase[1].p1+nf+gansphrase[1].p2+ns+gansphrase[1].p3+scinot(energy)+"Joules"
		theanswer=theanswer+convertphrase
		}
	else {
		theanswer=introphrase[2].p1+given[question[which].p5]+introphrase[2].p2;	
	theanswer=theanswer+ansphrase[which].p1+gansphrase[2].p1+n1+gansphrase[2].p2+scinot(energy)+gansphrase[2].p3+n2*n2+gansphrase[2].p4+n2+gansphrase[2].p5
	}
}
function answer(theans){
	if(tried==1)alert("You've done this one. Get a new problem!")
	else{
	if(tried==2){totl++;document.forms[0].total.value=totl}
	attempts++
	if(theans>.95*ans & theans<1.05*ans){
		document.forms[0].results.value="Correct"
		corrt++
		document.forms[0].correct.value=corrt
		tried=1
	}
	else{
		document.forms[0].results.value="Incorrect"
		tried=2
	}
}}
function sigfigs(f){
ex=0
if(Math.abs(f)>1000){
	while(Math.abs(f)>1000){
		ex++
		f=f/10
	}
f=Math.round(f)/100
ex=ex+2
f=""+f
if(f.length==1){f=f+"."}
while(f.length<4){f=f+"0"}
	f=f+"e"+ex
	return f
	}
else{if(Math.abs(f)<100){
	while(Math.abs(f)<100){
		ex++
		f=f*10
	}
	f=Math.round(f)/100
	ex=2-ex
	f=""+f
	if(f.length==1){f=f+"."}
	while(f.length<4){f=f+"0"}
	if(ex!=0){f=f+"e"+ex}
	return f}
else{
	f=Math.round(f)/100+"e"+2
	f=""+f
	if(f.length==1){f=f+"."}
	while(f.length<4){f=f+"0"}
	return f
	}
	}
}
function scinot(x){
	split=x.indexOf("e")
	coeff=x.substring(0,split)
	expon=x.substring(split+1,x.length)
	sciform=coeff+"*10<sup>"+expon+"</sup>"
	return sciform
}
