diff options
Diffstat (limited to '1415/CH1/EX1.2.1')
-rw-r--r-- | 1415/CH1/EX1.2.1/ex1.jpg | bin | 0 -> 51831 bytes | |||
-rw-r--r-- | 1415/CH1/EX1.2.1/ex1.sce | 49 |
2 files changed, 49 insertions, 0 deletions
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');
|