diff options
Diffstat (limited to '1415/CH1')
32 files changed, 570 insertions, 0 deletions
diff --git a/1415/CH1/EX1.1.1/ex1.jpg b/1415/CH1/EX1.1.1/ex1.jpg Binary files differnew file mode 100644 index 000000000..11abf053b --- /dev/null +++ b/1415/CH1/EX1.1.1/ex1.jpg diff --git a/1415/CH1/EX1.1.1/ex1.sce b/1415/CH1/EX1.1.1/ex1.sce new file mode 100644 index 000000000..14996531e --- /dev/null +++ b/1415/CH1/EX1.1.1/ex1.sce @@ -0,0 +1,42 @@ +//Example 1 Page 44
+clc
+clear
+function y=f(x)//defining the fcuntion
+y=-x^2+20*x+3;
+endfunction
+
+disp('a)')
+disp(poly([3 20 -1],'x','c'))//displaying the polynomial
+disp('for the year 2004, the value of x = 0')
+x=0;
+p=f(x);//function calling
+mprintf("the sales of ipod in the year 2004 are %d",p);//displaying result
+disp('for the year 2005, the value of x = 1')
+x=1;
+p=f(x);//function calling
+mprintf("the sales of ipod in the year 2005 are %d",p);//displaying result
+disp('for the year 2006, the value of x = 2')
+x=2;
+p=f(x);//function calling
+mprintf("the sales of ipod in the year 2006 are %d",p);//displaying result
+disp('for the year 2007, the value of x = 3')
+x=3;
+p=f(x);//function calling
+mprintf("the sales of ipod in the year 2007 are %d",p);//displaying result
+disp('as -1 is not in the domain f(-1) is not defined')
+
+disp('b)')
+a=poly(0,'a');//generating polynomial
+p=f(a)//function calling
+disp(p)
+b=poly(0,'b');//generating polynomial
+p=f(-b);//function calling
+disp(p)
+
+disp('c)')
+x=([0 1 2 3])//assigning values to x
+y=f(x)////function calling
+disp('x=',x)
+disp('y=',y)
+plot(x,y)//plotting the values on graph
+xtitle('Graph f','x','y');
diff --git a/1415/CH1/EX1.1.2/ex2.jpg b/1415/CH1/EX1.1.2/ex2.jpg Binary files differnew file mode 100644 index 000000000..6cff0e62a --- /dev/null +++ b/1415/CH1/EX1.1.2/ex2.jpg diff --git a/1415/CH1/EX1.1.2/ex2.sce b/1415/CH1/EX1.1.2/ex2.sce new file mode 100644 index 000000000..bb851ea02 --- /dev/null +++ b/1415/CH1/EX1.1.2/ex2.sce @@ -0,0 +1,31 @@ +//Example 2 Page 47
+clc
+clear
+//defnining the function
+function y=n(t)
+if(t>0 | t<=3) then
+y=1.5*t^2-t+1.5;
+elseif(t>3 | t<=5) then
+y=46*t-126;
+end
+endfunction
+
+disp('jan.2005:')
+t=1;
+y=n(t)//calling function
+mprintf("the facebook memberships in the year 2005 are %d",y);//prinitng the value of the year 2005
+disp('jan.2007:')
+t=3;
+y=n(t)//calling function
+mprintf("the facebook memberships in the year 2007 are %d",y);//prinitng the value of the year 2007
+disp('jan.2008:')
+t=4.5;
+y=n(t)//calling function
+mprintf("the facebook memberships in the year 2005 are %d",y);//prinitng the value of the year 2008
+t=[0 1 2 3 ]//assigning values to t
+y=n(t)//finding the values of the function n(t)
+plot(t,y,'blue')//plotting on the graph
+t=([3 3.5 4 4.5 5])
+y=n(t)
+plot(t,y,'red')//plotting on the graph
+xtitle('Graph of n','Year','facebook members (in millions)');
diff --git a/1415/CH1/EX1.1.3/ex3.jpg b/1415/CH1/EX1.1.3/ex3.jpg Binary files differnew file mode 100644 index 000000000..f964038a8 --- /dev/null +++ b/1415/CH1/EX1.1.3/ex3.jpg diff --git a/1415/CH1/EX1.1.3/ex3.sce b/1415/CH1/EX1.1.3/ex3.sce new file mode 100644 index 000000000..e8362ff3b --- /dev/null +++ b/1415/CH1/EX1.1.3/ex3.sce @@ -0,0 +1,43 @@ +//Example 3 Page 48
+clc
+clear
+//defining the function
+function y=f(x)
+if(x >= -4 & x < -1) then//check value of x
+y=-1;
+elseif(x >= -1 & x <= 1) then//check value of x
+y=x;
+elseif(x > 1 & x <= 2) then//check value of x
+y=x^2-1;
+end
+endfunction
+
+disp('a)')
+x=-2;//assigning value to x
+y=f(x)//function calling
+disp(y)
+x=-1;//assigning value to x
+y=f(x)//function calling
+disp(y)
+x=0;//assigning value to x
+y=f(x)//function calling
+disp(y)
+x=1;//assigning value to x
+y=f(x)//function calling
+disp(y)
+x=2;//assigning value to x
+y=f(x)//function calling
+disp(y)
+
+disp('b)')
+x=[-4 -3 ]//assigning values to x
+y=f(x)//function calling
+disp(y)
+plot(4,4,x,y,'green')//plotting on graph
+x=[-1 0 1]//assigning values to x
+y=f(x)//function calling
+plot(4,4,x,y,'red')//plotting on graph
+x=[1.1 1.3 1.5 2]//assigning values to x
+y=f(x)//function calling
+plot(4,4,x,y,'blue')//plotting on graph
+xtitle('','x','y');
diff --git a/1415/CH1/EX1.2.1/ex1.jpg b/1415/CH1/EX1.2.1/ex1.jpg Binary files differnew file mode 100644 index 000000000..9b54171ee --- /dev/null +++ b/1415/CH1/EX1.2.1/ex1.jpg diff --git a/1415/CH1/EX1.2.1/ex1.sce b/1415/CH1/EX1.2.1/ex1.sce new file mode 100644 index 000000000..3ee7ed082 --- /dev/null +++ b/1415/CH1/EX1.2.1/ex1.sce @@ -0,0 +1,49 @@ +//Example 1 Page 57
+clc
+clear
+//defining the function
+function y=C(x)
+ y=1.6*x+1.9
+endfunction
+
+disp('a)')
+//for cost of 1-mile trip
+x=1
+y=C(x)//function calling
+mprintf("1-mile trip %f dollars\n",y)
+//for cost of 2-mile trip
+x=2
+y=C(x)//function calling
+mprintf("2-mile trip %f dollars\n",y)
+//for cost of 3-mile trip
+x=3
+y=C(x)//function calling
+mprintf("3-mile trip %f dollars\n",y)
+//so the cost of x-mile trip is
+x=poly([1.9 1.6],'x','coeff')
+disp(x)
+//the cost function is sum of two terms is the variable cost that depends on x, and the other is fixed cost which is independent
+disp('Cost=VariableCost + FixedCost')
+
+disp('b)')
+//cost of 40-mile trip is
+x=40
+y=C(x)
+mprintf("the cost of 40-mile trip is %f dollars",y)//displaying the cost of 40-mile trip
+
+disp('c)')
+//to calculate the cost of second mile
+x=1
+c1=C(x)//function calling
+x=2
+c2=C(x)//function calling
+cost=(c2-c1)//calculating the cost of second mile
+mprintf("cost of second mile is %f dollars",cost)
+
+disp('d)')
+x=[0 1 2]
+disp(x)
+y=C(x)//function calling
+disp(y)
+plot(7,5,x,y,'blue')//plotting the graph
+xtitle(' ','Miles','Dollars');
diff --git a/1415/CH1/EX1.2.2/ex2.jpg b/1415/CH1/EX1.2.2/ex2.jpg Binary files differnew file mode 100644 index 000000000..6b8839a37 --- /dev/null +++ b/1415/CH1/EX1.2.2/ex2.jpg diff --git a/1415/CH1/EX1.2.2/ex2.sce b/1415/CH1/EX1.2.2/ex2.sce new file mode 100644 index 000000000..d2daea230 --- /dev/null +++ b/1415/CH1/EX1.2.2/ex2.sce @@ -0,0 +1,35 @@ +//Example 2 Page 59
+clc
+clear
+//creating C(x) function
+function y=C(x)
+ y=100000+160*x-0.2*x^2
+endfunction
+
+//the variable cost is the part of the cost function that depends on x
+VariableCost=poly([0 160 -0.2],'x','c')//variablecost polynomial
+disp(VariableCost,'VariableCost in dollars=')
+FixedCost=100000
+disp(FixedCost,'FixedCost in dollars=')
+x=poly(0,'x')//x polynomial creation
+Rx=800*x//annual revence of x members
+//for the profit we use the formula
+Px=Rx-C(x)//displaying the P(x) value by subtracting C(x) from Rx
+disp('P(x)=R(x)-C(x)')
+disp(Px)
+r=roots(Px)//finding the roots of the quadratic equation obtained in P(x)
+disp(r)
+disp('since members cannot be in negative value we consider the positive value')
+
+x=[0 250]//taking random variables of x for graph
+y=C(x)//function calling
+plot(400,350000,x,y,'red')//plotting graph
+//creating the P(x) function
+function y=P(x)
+ y=-100000+640*x+0.2*x^2
+endfunction
+x=([0 150 350])//taking values of x for graph
+y=P(x)
+plot(x,y,'blue')//plotting graph
+xtitle(' ','x','y');
+
diff --git a/1415/CH1/EX1.2.3/ex3.jpg b/1415/CH1/EX1.2.3/ex3.jpg Binary files differnew file mode 100644 index 000000000..237184e82 --- /dev/null +++ b/1415/CH1/EX1.2.3/ex3.jpg diff --git a/1415/CH1/EX1.2.3/ex3.sce b/1415/CH1/EX1.2.3/ex3.sce new file mode 100644 index 000000000..81c171e8e --- /dev/null +++ b/1415/CH1/EX1.2.3/ex3.sce @@ -0,0 +1,27 @@ +//Example 3 Page no 60
+clc
+clear
+//creating function
+function q=f(p)
+ q=77.8*p^(-0.11)
+endfunction
+
+disp('a)')
+//plotting demand function
+disp('the demand curve is as in the graph')
+p=([200 400 500 800 1200 1600 2000 2200])
+y=f(p)
+plot(2400,50,p,y,'blue')//plotting graph
+
+disp('b)')
+//the demand at tuition costs of $1000 and $1500
+disp('the demand at tuition costs of $1000 and $1500')
+q=f(1000)//funcition calling
+mprintf("\t%f thousand students\n",q)
+q=f(1500)//funcition calling
+mprintf("\t%f thousand students\n",q)
+//the change in demand is therefore given as
+disp('the change in demand is therefore given as')
+change=(f(1500)-f(1000))//funcition calling
+mprintf("\t%f thousand students\n",change)
+xtitle('Technology formula','p','q');
diff --git a/1415/CH1/EX1.2.4/ex4.jpg b/1415/CH1/EX1.2.4/ex4.jpg Binary files differnew file mode 100644 index 000000000..ca9385a84 --- /dev/null +++ b/1415/CH1/EX1.2.4/ex4.jpg diff --git a/1415/CH1/EX1.2.4/ex4.sce b/1415/CH1/EX1.2.4/ex4.sce new file mode 100644 index 000000000..b14bc9345 --- /dev/null +++ b/1415/CH1/EX1.2.4/ex4.sce @@ -0,0 +1,33 @@ +//Example 4 Page 62
+clc
+clear
+function q1=f(p1)
+ q1=77.8*(p1^(-0.11))
+endfunction
+
+function q2=g(p2)
+ q2=30.4+0.006*p2
+endfunction
+disp('a)')
+p1=([200 400 800 1200 1600 2000 2200])
+q1=f(p1)
+plot(2400,50,p1,q1,'blue')
+
+p2=([200 400 800 1200 1600 2000 2200])
+q2=g(p2)
+plot(2400,50,p2,q2,'red')
+
+disp('the lines cross at $1000 at Equilibrium point')
+disp(f(1000),'Demand:')
+disp(g(1000),'Supply:')
+disp('so 36400 students')
+
+disp('b)')
+disp('If tuition is, say, $1,800, then the supply will be larger thandemand and there will be a surplus of available openings at private schools. Similarly, iftuition is less—say $400—then the supply will be less than the demand, and there willbe a shortage of available openings.')
+
+disp('c)')
+//tuition fee set at &1200
+disp(f(1200),'Demand in thousand seats')
+disp(g(1200),'Supply in thousand seats')
+disp(g(1200)-f(1200),'Surplus is given in thousand seats as:')
+xtitle('Demand and Supply','p','q');
diff --git a/1415/CH1/EX1.2.5/1.jpg b/1415/CH1/EX1.2.5/1.jpg Binary files differnew file mode 100644 index 000000000..6b4c340eb --- /dev/null +++ b/1415/CH1/EX1.2.5/1.jpg diff --git a/1415/CH1/EX1.2.5/3.jpg b/1415/CH1/EX1.2.5/3.jpg Binary files differnew file mode 100644 index 000000000..aa3aabf00 --- /dev/null +++ b/1415/CH1/EX1.2.5/3.jpg diff --git a/1415/CH1/EX1.2.5/ex5.sce b/1415/CH1/EX1.2.5/ex5.sce new file mode 100644 index 000000000..7323e28ce --- /dev/null +++ b/1415/CH1/EX1.2.5/ex5.sce @@ -0,0 +1,54 @@ +//Example 5 Page 64
+clc
+clear
+//function for linear model
+function y=r1(t)
+y=57*t+607
+endfunction
+//function for quadratic model
+function y=r2(t)
+ y=-9*t^2+110*t+560
+endfunction
+//function for exponential model
+function y=r3(t)
+ y=608*(1.08)^t
+endfunction
+//function for logistic model
+function y=r4(t)
+ y=930/(1+0.67*(1.7)^-t)
+endfunction
+
+disp('a)')
+t=([0 1 2 3 4 5 6])//assigning values of t
+y1=r1(t)//function caling r1(t)
+disp(t)
+disp(y1)//displaying values of y1
+y2=r2(t)//function calling r2(t)
+disp(t)
+disp(y2)//displaying values of y2
+y3=r3(t)//function calling r3
+disp(t)
+disp(y3)//displaying value sof y3
+y4=r4(t)//function calling r4
+disp(y3)//displaying y4 values
+plot(6,1000,t,y1,'red')//plotting linear graph
+xtitle('Linear Model','x','y')//given title and other labes
+scf//setting current graphic window
+plot(6,1000,t,y2,'blue')//plotting qudratic graph
+xtitle('quadratic','x','y')//setting labels
+scf//setting current graphic window
+plot(6,1000,t,y3,'blue')//plotting exponential graph
+xtitle('Exponential Model','x','y')//setting labels
+scf//setting current graphic window
+plot(6,1000,t,y2,'blue')//plotting logistic graph
+xtitle('Logistic Model','x','y')//setting labels
+
+disp('b)')
+t=10//assigning value of t
+y1=r2(t)//function calling r2
+disp(y1,'Quadratic Model for 2010')//displaying result
+y2=r4(t)//function calling r4
+disp(y2,'Logistic Model for 2010')//displaying result
+
+
+
diff --git a/1415/CH1/EX1.3.1/ex1.jpg b/1415/CH1/EX1.3.1/ex1.jpg Binary files differnew file mode 100644 index 000000000..05a2c1c48 --- /dev/null +++ b/1415/CH1/EX1.3.1/ex1.jpg diff --git a/1415/CH1/EX1.3.1/ex1.sce b/1415/CH1/EX1.3.1/ex1.sce new file mode 100644 index 000000000..4c1c68ede --- /dev/null +++ b/1415/CH1/EX1.3.1/ex1.sce @@ -0,0 +1,19 @@ +//Example 1 Page 78
+clc
+clear
+//The function f cannot be linear.If it were, we would have delta f=m*deltax//
+disp(-4/2,'the ratio deltag/deltax is the same each time namely -4/2=')
+disp('hence g is linear with slop m=-2.By the table g(0)=3 hence b =3')
+disp('g(x)=-2x+3');
+x=[0 2 4 6 8 10 12]// taking the x values as in the example
+disp(x,'x')//displaying the same
+f=[3 -1 -3 -6 -8 -13 -15]//taking the f(x) values
+disp(f,'f(x)')//displaying the same
+plot(x,f,'blue')//plotting the f(x) graph with 'blue' colour//
+xtitle('f(x) Graph','x','f(x)')//xtitle gives the title to the graph first parameter is the title, the other two specify the axes names
+g=[3 -1 -5 -9 -13 -17 -21]
+disp(x,'x');//displaying x values
+disp(g,'g(x)')//displaying g(x) values
+plot(x,g,'red')//plotting the graph with colour red
+xtitle('g(x) Graph','x','g(x)')////xtitle gives the title to the graph first parameter is the title, the other two specify the axes names
+
diff --git a/1415/CH1/EX1.3.2/ex2.sce b/1415/CH1/EX1.3.2/ex2.sce new file mode 100644 index 000000000..83d591c12 --- /dev/null +++ b/1415/CH1/EX1.3.2/ex2.sce @@ -0,0 +1,47 @@ +//Example 2 Page 81
+clc
+clear
+disp('a)')
+disp('two write the equation we need the two values one is the slope m and other is y intercept b')
+disp('the given points are')
+disp('(1,2),(3,-1)')
+y2=-1;//assigning the values
+y1=2;//assigning the values
+x1=1;//assigning the values
+x2=3;//assigning the values
+m=(y2-y1)/(x2-x1);//calculating m value
+mprintf("the slope of the line m = %f",m);//printing the valye m
+disp('we now find the y intercept b')
+b=y1-m*x1;//calculating the value b
+mprintf("the value of b = %f",b);//printing the valye b
+disp('substituting the values m and b in the equation we get the equation of the line is')
+disp('y=3x/2+7/2')
+
+disp('b)')
+// we dont have the two points here but we have the parallel line
+disp('the line parallel has the same slope ')
+//the given line is 3x+4y=5
+m=-3/4//assigning the slope value
+disp('we now have the slope and also the point (2,-2)')
+x1=2//assigning the value of x1
+y1=-2//assigning the value of y1
+b=y1-m*x1;//calculating b value
+disp(b,'b=-2-(-3/4)(2)=')
+disp('substituting the values m and b in the equation y=mx+c, we get' )
+disp('y=-3x/4-7/2')
+
+
+disp('c)')
+//since the line is horizontal it means that the slope m = 0
+disp('the point is (-9,5)')
+m=0//since the line is horizontal
+x1=-9//assigning the valye
+y1=5//assigning the value
+b=y1-m*x1;//calculating b value
+ disp(b,'5-(0)(-9)=')//displaying the value of b
+ disp('the line is y=5')//displaying line quation
+
+
+disp('d)')
+//since the line is vertical the slope is undefined
+disp('the line can be any solution so we take it as x=-9')
diff --git a/1415/CH1/EX1.3.3/ex3.jpg b/1415/CH1/EX1.3.3/ex3.jpg Binary files differnew file mode 100644 index 000000000..962b3114c --- /dev/null +++ b/1415/CH1/EX1.3.3/ex3.jpg diff --git a/1415/CH1/EX1.3.3/ex3.sce b/1415/CH1/EX1.3.3/ex3.sce new file mode 100644 index 000000000..a274c10f7 --- /dev/null +++ b/1415/CH1/EX1.3.3/ex3.sce @@ -0,0 +1,24 @@ +//Example 3 Page 82
+clc
+clear
+C1=25000//assigning C1 value
+x1=30//Assigning x1 value
+C2=30000//assigning C2 value
+x2=40//assigning x2 value
+m=((C2-C1)/(x2-x1));//Finding the slopw
+disp(m,'the slope is')//displaying the slope value
+b=C1-m*x1;//Finding the intercept value
+disp(b,'the intercept b is')//dislaying the intercept value
+//therefore the function is C(x)
+function y=C(x)//function C(x)
+ y=500*x+10000
+endfunction
+
+x=[0 10 20 30 40 50]//assigning values of x for graph
+y=C(x)//function calling
+disp(x,'x:')//displaying x
+disp(y,'y:')//displaying y
+plot(x,y,'blue')//plotting graph in blue colour
+xtitle('','Number of Refrigerators','Cost(dollars)')//naming the axes
+
+
diff --git a/1415/CH1/EX1.3.4/ex4.sce b/1415/CH1/EX1.3.4/ex4.sce new file mode 100644 index 000000000..77f34bb8c --- /dev/null +++ b/1415/CH1/EX1.3.4/ex4.sce @@ -0,0 +1,37 @@ +//Example 4 Page 83
+clear
+clc
+
+disp('a)')
+q2=350//assigning the q2 value
+q1=400//assigning the q1 value
+p2=0.75//assigning the p2 value
+p1=0.50//assigning the p1 value
+m1=((q2-q1)/(p2-p1));//finding the slope value
+disp(m1,'the slope m is')//displaying the slope value
+b1=q1-m1*p1//finding the intercept value
+disp(b1,'the intercept value b')//displaying the intercept value
+mprintf("so the demand equation is q=%dp+%d",m1,b1);//displaying the demand function
+
+q2=500//assigning the q2 value
+q1=300//assigning the q1 value
+p2=0.75//assigning the p2 value
+p1=0.50//assigning the p1 value
+m2=((q2-q1)/(p2-p1));//finding the slope value
+disp(m2,'the slope m is')//displaying the slope value
+b2=q1-m2*p1;//finding the intercept value
+disp(b2,'the intercept value b')//displaying the intercept value
+mprintf("so the supply equation is q=%dp%d",m2,b2);//displaying the supply curve
+
+disp('b)')
+disp('In deamnd equation the slope m = -200, since m is negative, we see that the number of cans sold decreases as the price increases')
+disp('In supplyequation the slope m = 800, since we conclued that the weekly supply increases by 800 cans per $1 increase')
+
+disp('c)')
+p=600/1000;//finding the p value
+disp(p,'the p value is(dollars):')//displaying the p value
+q=m1*p+b1;//fincind the q value
+disp('the corresponding demand is:")//displaying the q value
+mprintf(" %d cans per week",q)//printing the q value
+
+
diff --git a/1415/CH1/EX1.3.5/ex5.sci b/1415/CH1/EX1.3.5/ex5.sci new file mode 100644 index 000000000..e097bdffd --- /dev/null +++ b/1415/CH1/EX1.3.5/ex5.sci @@ -0,0 +1,23 @@ +//Example 6 Page 86
+clc
+clear
+
+disp('a)')
+s2=530//Assigning s2 values
+s1=50//Assigning s1 values
+t2=8//Assigning t2 values
+t1=0//Assigning t1 values
+m=((s2-s1)/(t2-t1));//calculating m value
+disp(m,'the slope is:')//displaying m value
+b=s1-m*t1;//calculating b value
+disp(b,'the intercept value is')//displaying b value
+mprintf( "So, %dt+%d million units ",m,b);//printing the s equation
+
+disp('b)')
+mprintf( "So, %dt+%d million units\n ",m,b);//printing the s equation
+//since value of s=440
+s=440//Assigning s values
+m=60//Assigning m values
+b=50//Assigning b values
+t=(s-b)/60;//calculting time
+mprintf("\nAnnual sales of mobile portable devices will reah 440 millions when s=440 or t=%f years",t);//displaying the time in years
diff --git a/1415/CH1/EX1.3.6/ex6.jpg b/1415/CH1/EX1.3.6/ex6.jpg Binary files differnew file mode 100644 index 000000000..664e2fc69 --- /dev/null +++ b/1415/CH1/EX1.3.6/ex6.jpg diff --git a/1415/CH1/EX1.3.6/ex6.sci b/1415/CH1/EX1.3.6/ex6.sci new file mode 100644 index 000000000..718953fcd --- /dev/null +++ b/1415/CH1/EX1.3.6/ex6.sci @@ -0,0 +1,13 @@ +//Example 6 Page 86
+clc
+clear
+
+function s=S(t)//function for s(t)
+ s=54*t+20
+endfunction
+t=[0 0.5 1 1.5 2]//values of t given in question
+disp(t,'time(h)')//displaying the t values
+s=S(t);//function calling
+disp(s,'marker(mi)')//displaying the s values
+plot(t,s,'blue')//plotting the graph
+xtitle('','Time(hours)','Location(miles)')//naming the axes
diff --git a/1415/CH1/EX1.4.1/1.jpg b/1415/CH1/EX1.4.1/1.jpg Binary files differnew file mode 100644 index 000000000..9d2779b07 --- /dev/null +++ b/1415/CH1/EX1.4.1/1.jpg diff --git a/1415/CH1/EX1.4.1/2.jpg b/1415/CH1/EX1.4.1/2.jpg Binary files differnew file mode 100644 index 000000000..ec16593ca --- /dev/null +++ b/1415/CH1/EX1.4.1/2.jpg diff --git a/1415/CH1/EX1.4.1/ex1.sce b/1415/CH1/EX1.4.1/ex1.sce new file mode 100644 index 000000000..660d25bcb --- /dev/null +++ b/1415/CH1/EX1.4.1/ex1.sce @@ -0,0 +1,38 @@ +//Example 1 Page 96
+clc
+clear
+function y1=Y1(t)//function for y=0.5t+8
+ y1=0.5*t+8
+endfunction
+
+function y2=Y2(t)//function for y=0.25+9
+ y2=0.25*t+9
+endfunction
+
+t=[0 2 4 6 8 10 12 14]//t values as given in question
+disp(t,'Year:')//displaying t values
+y=[9 9 10 11 11 12 13 13]//y values as given in question
+disp(y,'observed:')//displaying y values
+y1=Y1(t)//function calling
+disp(y1,'Predicted:')//printing predicted values
+disp(y-y1,'Residual:')//printing residual values
+disp((y-y1)^2,'Residual square')//printing residual square values
+
+t=[0 2 4 6 8 10 12 14]//t values as given in question
+disp(t,'Year:')//displaying t values
+y=[9 9 10 11 11 12 13 13]//y values as given in question
+disp(y,'observed:')//dispalying observed values
+y2=Y2(t)//function valling
+disp(y2,'Predicted:')//printing predicted values
+disp(y-y2,'Residual:')//printing residual values
+disp((y-y2)^2,'Residual square')//printing residual square values
+
+
+plot(t,y1)//plotting graph between t and y
+xtitle('y=0.5t+8','t','y')//naming the axes
+scf;//setting the current graphic window
+plot(t,y2)//plotting the graph between t and y
+xtitle('y=0.25t+9','t','y')//naming the axes
+
+
+
diff --git a/1415/CH1/EX1.4.2/ex2.jpg b/1415/CH1/EX1.4.2/ex2.jpg Binary files differnew file mode 100644 index 000000000..5542e2e1c --- /dev/null +++ b/1415/CH1/EX1.4.2/ex2.jpg diff --git a/1415/CH1/EX1.4.2/ex2.sci b/1415/CH1/EX1.4.2/ex2.sci new file mode 100644 index 000000000..2de9e56e5 --- /dev/null +++ b/1415/CH1/EX1.4.2/ex2.sci @@ -0,0 +1,28 @@ +//Example 2 Page 98
+clc
+clear
+
+x=[0 2 4 6 8 10 12 14]//assigning x values as given
+disp(x,'Years:')//displaying the x values
+y=[9 9 10 11 11 12 13 13]//assigning the y values
+disp(y,'Per capital GDP:')//displaying y values
+xy=x.*y//calculating xy values
+disp(xy,'xy:')//displaying xy values
+x2=x^2//calculating x^2 values
+disp(x2,'square of x')//displaying x^2 values
+n=8;//given n=8 data points
+disp(sum(x),'sumof x:')//finding the sum of x
+disp(sum(y),'sumof y:')//finding the sum of y
+disp(sum(xy),'sumof xy:')//finding the sum of xy
+disp(sum(x2),'sumof xsquare:')//finding the sum of x2
+m=((n*(sum(xy)))-((sum(x))*(sum(y))))/((n*(sum(x2)))-(sum(x)^2));//calculating m value
+disp(m,'m value is:')//displaying m values
+b=(sum(y)-(m*sum(x)))/n//calculating b value
+disp(b,'b value is:')//displaying b value
+
+function y=f(x)//function for regression line
+ y=m*x+b
+endfunction
+y=f(x)//calling function
+plot(x,y)//plotting graph between x and y
+xtitle('data point and regression line','x','y')//naming the axex
diff --git a/1415/CH1/EX1.4.3/ex3.sce b/1415/CH1/EX1.4.3/ex3.sce new file mode 100644 index 000000000..9053c2ed6 --- /dev/null +++ b/1415/CH1/EX1.4.3/ex3.sce @@ -0,0 +1,27 @@ +//Example 3 Page 100
+clc
+clear
+
+x=[0 2 4 6 8 10 12 14]//assigning the values of x
+y=[9 9 10 11 11 12 13 13]//assigning the values of y
+disp(x,'x:')//displaying x values
+disp(y,'y:')//displaying y values
+xy=x.*y//calculating xy
+disp(xy,'xy:')//displaying xy values
+x2=x^2;//calculating x^2 values
+disp(x2,'x square:')//displaying x^2 values
+y2=y^2;//calculating y^2 values
+disp(y2,'y square:')//displaying y^2 values
+sumx=sum(x)//calculating sum of x
+disp(sumx,'sum(x)')//displaying x values
+sumy=sum(y)//calculating sum of y
+disp(sumy,'sum(y)')//displaying y values
+sumxy=sum(xy)//calculating sum of xy
+disp(sumxy,'sum(xy)')//displaying xy values
+sumx2=sum(x2)//calculating sum of x^2
+disp(sumx2,'sum(x2)')//displaying x^2 values
+sumy2=sum(y2)//calculating sum of y^2
+disp(sumy2,'sum(y2)')//displaying y^2 values
+n=8//given as n=8
+r=(((n*(sumxy))-(sumx*sumy))/((sqrt((n*sumx2)-((sumx)^2)))*(sqrt((n*sumy2)-((sumy)^2)))))//calculating r value
+disp(r,'the value of r is :')//displaying r value
|