#"The slope of line through A(2,2) and B(3,4) is :" #
#m=(4-2)/(3-1)=2/1=2#
#"now,let us find the slope of line passing C(6,8) and D(x,y)"#
#"if two line is perpendicular , product of their slopes is equal to -1"#
#m*n=-1#
#2*n=-1#
#n=-1/2#
#"now ,let us write equations of lines "#
#"equation for line passing A(2,2) and D(x,y)"#
#y-2=2(x-2)#
#y=2x-4+2#
#y=2x-2" (1)"#
#"equation for line passing C(6,8) and D(x,y)"#
#y-8=-1/2(x-6)#
#y=-1/2 (x-6)+8#
#y=-1/2 x+3+8#
#y=-1/2 x+11" (2)"#
#"let us write the equations (1) and (2) as equal "#
#2x-2=-1/2 x+11#
#2x+1/2 x=11+2#
#5/2 x=13" , "5x=13*2" ," x=26/5" , "x=5.2#
#"use equation (1) or (2)"#
#y=2x-2#
#"insert x=5.2"#
#y=2*5.2-2#
#y=10.4-2#
#y=8.4#
#D=(5.2,8.4)#
#"the end points are C(6,8) and D(5.2,8.4)"#
#"The length of the altitude can be calculated using :"#
#h_C=sqrt((5.2-6)2+(8.4-8)^2)#
#h_C=sqrt((-0.8)+(0.4)^2)#
#h_C=sqrt(0.64+0.16)#
#h_C=sqrt(0.80)#
#h_C=0.89#