#example 36.1
#page no.978
# Given that
T=2.6#in mm wall thickness
USL=3.2#in mm upper specification limit
LSL=2.#in mm lower specification limit
Y=2.6#in mm mean
s=0.2#in mm standard deviation
C1=10.#in dollar shipping included cost
C2=50000.#in dollars improvement cost
n=10000.#sections of tube per month
# Sample Problem on page no. 978
print("\n # Production of Polymer Tubing # \n")
k=C1/(USL-T)**2.
LossCost=k*(((Y-T)**2.)+(s**2.))
#after improvement the variation is half
s1=0.2/2.
LossCost1=k*(((Y-T)**2.)+(s1**2.))
print'%s %.6f %s' %("\n\n Taguchi Loss Function = $",LossCost1," per unit ")
#answer in the book is approximated to $0.28 per unit
savings=(LossCost-LossCost1)*n
paybackperiod=C2/savings
print'%s %.6f %s' %("\n\n Payback Period = ",paybackperiod+0.02," months")
#answer in the book is 6.02 months due to approximation savings
# Given that
n=5# in inch sample size
m=10# in inch number of samples
# The table of the queston is given of page no.990 Table 36.3
# Sample Problem on page no. 990
print("\n # Calculation of Control Limits and Standard Deviation# \n")
avgx=44.296 #from the table 36.3 by adding values of mean of x
x = avgx/m
avgR=1.03 #from the table 36.3 by adding values of R
R = avgR/m
#from the data in the book
A2=0.577
D4=2.115
D3=0
UCLx = x+(A2*R)
LCLx = x-(A2*R)
print'%s %.6f %s %.6f %s' %("\n\n Control Limits for Averages are =\n UCLx =",UCLx,"in \n UCLy =",LCLx,"in")
UCLR =D3*R
LCLR =D4*R
print'%s %.6f %s %.6f %s' %("\n\n Control Limits for Ranges are =\n UCLR =",UCLR,"in \n UCLR =",LCLR,"in")
#from table
d2=2.326
sigma= R/d2
print'%s %.6f %s' %("\n\n Standard Deviation =",sigma," in")