80 likes | 191 Views
Sample Solutions:. Calculate the integral with; a) Trapezoidal rule b) Simpson’s rule c) With computer (Visual Basic), take m=2, n=4. a) Trapezoidal rule: Divide into for equal section between 0.5 and 1. Sample Solutions:. c) With computer (Visual Basic). Sub simpson_Click ()
E N D
Sample Solutions: Calculate the integral with; a) Trapezoidal rule b) Simpson’s rule c) With computer (Visual Basic), take m=2, n=4. a) Trapezoidal rule: Divide into for equal section between 0.5 and 1.
Sample Solutions: c) With computer (Visual Basic) Sub simpson_Click () 80 a = .5: b = 1: m = 2 … 85 f = Sqr(x) * Cos(x) … End Sub b) Simpson’s rule: with Matlab >>I=int('sqrt(tet)*cos(tet)',0.5,1);vpa(I,5) I=0.30796
Sample Solutions: b) For computer solution, the file li.txt is arranged as follows and the code Lagr.I is run. li.txt 3 3,7 8,6.2 10,6 5 • The pressure values of a fluid flowing in a pipe are given in the table for different locations . Find the pressure value for 5 m. • a) Lagrange interpolation (manually) • with computer a) with Lagrange interpolation
Sample Solutions: How do you find x and y values, which satisfy the equations? with Matlab: >>[x,y]=solve('sin(2*x)+y^3=3*x-1','x^2+y=1-y^2') x=0.6786, y=0.3885 Sub newtonrn_Click () 40 n = 2 … 41 xb(1) = 1: xb(2) = 1: xh(1) = .001: xh(2) = .001 … 45 '---- Error equations ----------- a(1, 1) = 2 * Cos(2 * xb(1)) - 3: a(1, 2) = 3 * xb(2) ^ 2 a(2, 1) = 2 * xb(1): a(2, 2) = 2 * xb(2) + 1 b(1) = -(Sin(2 * xb(1)) + xb(2) ^ 3 - 3 * xb(1) + 1) b(2) = -(xb(1) ^ 2 + xb(2) ^ 2 + xb(2) - 1) 46 '-------------------- … End Sub x=0.6786 y=0.3885
Sample Solutions: F b A As a result of the equilibrium conditions, the equations given below are obtained for a truss system. How do you calculate the member forces FJD, FFD, FCD and FFC if FCK=6.157 kN and FCB=-3.888 kN are known?
Sample Solutions: with Matlab clc;clear A=[-1 -0.707 -0.894 0;0 -0.707 -1 0;3 0 0 2.365;0 0 0.894 1]; b=[-0.466;0;-6.557;4.353]; F=inv(A)*b FJD= 1.5429 kN FFD= -14.3701 kN FCD= 10.1596 kN FFC= -4.7297 kN F b A
Sample Solutions: Find the roots of the polynomial. with Matlab >> p=[3 0 5 6 -20] >> roots(p) >>ezplot('3*t^4+5*t^2+6*t-20',-2,2) ans = -1.5495 0.1829 + 1.8977i 0.1829 - 1.8977i 1.1838