u1=1
v1=1
w1=0
u2=0
v2=1
w2=0
u3=-1
v3=1
w3=1
import math
phi=math.acos((u1*u2+v1*v2+w1*w2)/(math.sqrt((u1**2+v1**2+w1**2)*(u2**2+v2**2+w2**2))))
lam=math.acos((u3*u2+v3*v2+w3*w2)/(math.sqrt((u3**2+v3**2+w3**2)*(u2**2+v2**2+w2**2))))
sigma=52 #in MPa, Tensile stress
tr=sigma*math.cos(phi)*math.cos(lam)
trc=30 #in MPa Critical resolved shear stress
sy=trc/(math.cos(phi)*math.cos(lam))
print"(a)The resolved shear stress is ",round(tr,2),"MPa"
print"(b)Yield strength is",round(sy,1),"MPa"
df=12.2 #Final dia in mm
di=15.2 #Initial dia in mm
CW = ((di**2-df**2)/di**2)*100
ts=340 #in Mpa tensile strength, from fig 7.19 (b)
duc=7 #in % Ductility from fig 7.19 (c)
print"Percent Cold Work is ",round(CW,1),"%"
print"Tensile strength is",ts,"MPa"
print"Ductility is ",duc,"%"
di=6.4 #Initial dia in mm
df=5.1 #Final dia in mm
CW = ((di**2-df**2)/di**2)*100
dmid = math.sqrt(df**2/(1-0.215))
print"Cold work is ",round(CW,1),"%"
print"But required ductility and yield strength is not matched at this cold work"
print"Hence required Cold work is 21.5 %"
print"Hence original diameter for second drawing is ",round(dmid,1),"mm"