HW06_soln

# HW06_soln - 395 Columns 37 593 1780 890 445 1336 Columns 43...

This preview shows pages 1–3. Sign up to view the full content.

Problem 1: function out = ptoxyf( amplitude,angle) % A script to convert vectors from polar (length,angle) % coordinates to xy coordinates. x = amplitude*cosd( angle ); y = amplitude*sind( angle); out = [x y]; >> y = ptoxyf( 100,45 ) y = 70.7107 70.7107 >> y = ptoxyf( 48,240 ) y = -24.0000 -41.5692 >> >> type int_series Problem 2: function out = int_series( n ) if ( n <= 0 | fix( n ) ~= n ) error( 'Not a Positive Integer' ); end out = n; while ( n ~= 1 ) if ( rem(n,2) == 0 ) n = n/2; else n = 3*n+1; end out = [out n]; end >> y = int_series( 1 ) y = 1 >> y = int_series( 24 ) y = 24 12 6 3 10 5 16 8 4 2 1 >> y = int_series( 17 ) y = 17 52 26 13 40 20 10 5 16 8 4 2 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
>> y = int_series( 27 ) y = Columns 1 through 6 27 82 41 124 62 31 Columns 7 through 12 94 47 142 71 214 107 Columns 13 through 18 322 161 484 242 121 364 Columns 19 through 24 182 91 274 137 412 206 Columns 25 through 30 103 310 155 466 233 700 Columns 31 through 36 350 175 526 263 790
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 395 Columns 37 through 42 1186 593 1780 890 445 1336 Columns 43 through 48 668 334 167 502 251 754 Columns 49 through 54 377 1132 566 283 850 425 Columns 55 through 60 1276 638 319 958 479 1438 Columns 61 through 66 719 2158 1079 3238 1619 4858 Columns 67 through 72 2429 7288 3644 1822 911 2734 Columns 73 through 78 1367 4102 2051 6154 3077 9232 Columns 79 through 84 4616 2308 1154 577 1732 866 Columns 85 through 90 433 1300 650 325 976 488 Columns 91 through 96 244 122 61 184 92 46 Columns 97 through 102 23 70 35 106 53 160 Columns 103 through 108 80 40 20 10 5 16 Columns 109 through 112 8 4 2 1 Problem 3: function out = pie_estimate( tol ) y = 0; n = 0; err = tol+1; % Insures while start while ( err > tol ) n = n+1; term = 1/n^2; y = y + term; err = abs( term/y ); end out = sqrt(y*6); >> y = pie_estimate( 0.01 ) y = 3.0395 >> y = pie_estimate( 0.001 ) y = 3.1039 >> y = pie_estimate( 1e-6 ) y = 3.1404 >> y = pie_estimate( 1e-7 ) y = 3.1412...
View Full Document

## This note was uploaded on 05/04/2010 for the course ECO 304K taught by Professor Hickenbottom during the Spring '10 term at University of Texas.

### Page1 / 3

HW06_soln - 395 Columns 37 593 1780 890 445 1336 Columns 43...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online