# # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- save_plots = F # Chapter 7: Section 6: Exercise 27 # x = seq( from=-5, to=15, length.out=100 ) y1 = 4 + x y2 = 0.5 * x - 2 max_E = max( c(y1,y2) ) min_E = min( c(y1,y2) ) if( save_plots ){ postscript("../../WriteUp/Graphics/Chapter7/section_6_exercise_27_primal_problem.eps", onefile=FALSE, horizontal=FALSE) } plot( x, y1, type='l', col='blue', xlim=c(-2.5,+10), ylim=c(min_E,max_E), xlab='x' ) lines( x, y2, type='l', col='red' ) abline( v=0 ) abline( h=0 ) polygon( c(0,0,4,12,12), c(4,0,0,4,16), col='gray' ) grid() if( save_plots ){ dev.off() } v = seq( from=-5, to=15, length.out=100 ) v1 = 1 + 0.5 * v v2 = -0.75 + 0.25 * v max_E = max( c(v1,v2) ) min_E = min( c(v1,v2) ) if( save_plots ){ postscript("../../WriteUp/Graphics/Chapter7/section_6_exercise_27_dual_problem.eps", onefile=FALSE, horizontal=FALSE) } plot( v, v1, type='l', col='blue', xlim=c(-2.5,+10), ylim=c(min_E,max_E), xlab='v' ) lines( v, v2, type='l', col='red' ) abline( v=0 ) abline( h=0 ) polygon( c(0,0,11,11), c(10,1,13/2,11), col='gray' ) polygon( c(11,11,3), c(0,2,0), col='gray' ) grid() if( save_plots ){ dev.off() }