save_figs = F # Question 9: # A = matrix( c( 1, 1, -2, 1 ), nrow=2, ncol=2, byrow=T ) b = c( 1, 1 ) x = solve( A, b ) print(x) ts = seq( 0, 10, length.out=100 ) #ys = x[1] * exp(r1 * ts) + x[2] * exp(r2 * ts) #plot(ts, ys) # Question 10: # A = matrix( c( 1, 1, -3, -1 ), nrow=2, ncol=2, byrow=T ) b = c( 2, -1 ) print( solve( A, b ) ) # Question 11: # A = matrix( c( 1, 1, 1/2, 1/3 ), nrow=2, ncol=2, byrow=T ) b = c( 4, 0 ) print( solve( A, b ) ) # Question 13: # r1 = ( -5 - sqrt(13) ) / 2 r2 = ( -5 + sqrt(13) ) / 2 A = matrix( c( 1, 1, r1, r2 ), nrow=2, ncol=2, byrow=T ) b = c( 1, 0 ) x = solve( A, b ) print( x ) ts = seq( 0, 5, length.out=100 ) ys = x[1] * exp(r1 * ts) + x[2] * exp(r2 * ts) if( save_figs ){ postscript("../../WriteUp/Graphics/Chapter3/chap_3_sect_1_prob_13_plot.eps", onefile=FALSE, horizontal=FALSE) } plot(ts, ys, type='l', xlab='t', ylab='y(t)', main='Question 13') grid() if( save_figs ){ dev.off() } # Question 14: # pr = polyroot( c( -4, 1, 2 ) ) print(pr) r1 = Re(pr[1]) # drop the 0 complex part r2 = Re(pr[2]) A = matrix( c( 1, 1, r1, r2 ), nrow=2, ncol=2, byrow=T ) b = c( 0, 1 ) x = solve( A, b ) print( x ) ts = seq( 0, 5, length.out=100 ) ys = x[1] * exp(r1 * ts) + x[2] * exp(r2 * ts) if( save_figs ){ postscript("../../WriteUp/Graphics/Chapter3/Chap_3_sect_1_prob_14_plot.eps", onefile=FALSE, horizontal=FALSE) } plot(ts, ys, type='l', xlab='t', ylab='y(t)', main='Question 14') grid() if( save_figs ){ dev.off() } # Question 15: # A = matrix( c( exp(1), exp(-9), exp(1), -9*exp(-9) ), nrow=2, ncol=2, byrow=T ) b = c( 1, 0 ) print( solve( A, b ) ) # Question 16: # A = matrix( c( exp(1), exp(+1), exp(-1)/2, -exp(+1)/2 ), nrow=2, ncol=2, byrow=T ) b = c( 1, -1 ) print( solve( A, b ) )