You are on page 1of 8

NAMA : SITI NUR QORI’AH

NIM : 1901014
PRODI : TEKNIK KIMIA “REGULER”
Ujian Tengah Semester Aplikom II
SOAL 1
Plot the polynomial y = x4 +x2 −1 between x = −2 and x = 2 (using fifty points).
Jawaban :
>> x= linspace(-2,2,50);
c= [1 0 1 0 -1];
y= polyval (c,x);
>> plot (x,y)

20

15

10

-5
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
NAMA : SITI NUR QORI’AH
NIM : 1901014
PRODI : TEKNIK KIMIA “REGULER”
Ujian Tengah Semester Aplikom II
Soal 2

Evaluate the function

for x = 3 to x = 5 in steps of 0.01


Jawaban :
x = 3 : 0.01 : 5;
g = x;
h = 1./x.^2;
f = x + h;
y = g./f

y=

Columns 1 through 12

0.9643 0.9646 0.9650 0.9653 0.9656 0.9660 0.9663 0.9666 0.9669 0.9672
0.9675 0.9678

Columns 13 through 24

0.9681 0.9684 0.9687 0.9690 0.9693 0.9696 0.9698 0.9701 0.9704 0.9707
0.9709 0.9712

Columns 25 through 36

0.9714 0.9717 0.9719 0.9722 0.9724 0.9727 0.9729 0.9732 0.9734 0.9736
0.9739 0.9741

Columns 37 through 48
NAMA : SITI NUR QORI’AH
NIM : 1901014
PRODI : TEKNIK KIMIA “REGULER”
Ujian Tengah Semester Aplikom II

0.9743 0.9745 0.9748 0.9750 0.9752 0.9754 0.9756 0.9758 0.9760 0.9762
0.9764 0.9766

Columns 49 through 60

0.9768 0.9770 0.9772 0.9774 0.9776 0.9778 0.9780 0.9781 0.9783 0.9785
0.9787 0.9788

Columns 61 through 72

0.9790 0.9792 0.9794 0.9795 0.9797 0.9798 0.9800 0.9802 0.9803 0.9805
0.9806 0.9808

Columns 73 through 84

0.9809 0.9811 0.9812 0.9814 0.9815 0.9817 0.9818 0.9820 0.9821 0.9822
0.9824 0.9825

Columns 85 through 96

0.9826 0.9828 0.9829 0.9830 0.9832 0.9833 0.9834 0.9835 0.9837 0.9838
0.9839 0.9840

Columns 97 through 108

0.9842 0.9843 0.9844 0.9845 0.9846 0.9847 0.9848 0.9850 0.9851 0.9852
0.9853 0.9854

Columns 109 through 120


NAMA : SITI NUR QORI’AH
NIM : 1901014
PRODI : TEKNIK KIMIA “REGULER”
Ujian Tengah Semester Aplikom II
0.9855 0.9856 0.9857 0.9858 0.9859 0.9860 0.9861 0.9862 0.9863 0.9864
0.9865 0.9866

Columns 121 through 132

0.9867 0.9868 0.9869 0.9870 0.9871 0.9871 0.9872 0.9873 0.9874 0.9875
0.9876 0.9877

Columns 133 through 144

0.9877 0.9878 0.9879 0.9880 0.9881 0.9882 0.9882 0.9883 0.9884 0.9885
0.9886 0.9886

Columns 145 through 156

0.9887 0.9888 0.9889 0.9889 0.9890 0.9891 0.9891 0.9892 0.9893 0.9894
0.9894 0.9895

Columns 157 through 168

0.9896 0.9896 0.9897 0.9898 0.9898 0.9899 0.9900 0.9900 0.9901 0.9902
0.9902 0.9903

Columns 169 through 180

0.9903 0.9904 0.9905 0.9905 0.9906 0.9906 0.9907 0.9908 0.9908 0.9909
0.9909 0.9910

Columns 181 through 192


NAMA : SITI NUR QORI’AH
NIM : 1901014
PRODI : TEKNIK KIMIA “REGULER”
Ujian Tengah Semester Aplikom II
0.9910 0.9911 0.9911 0.9912 0.9913 0.9913 0.9914 0.9914 0.9915 0.9915
0.9916 0.9916

Columns 193 through 201

0.9917 0.9917 0.9918 0.9918 0.9919 0.9919 0.9920 0.9920 0.9921


NAMA : SITI NUR QORI’AH
NIM : 1901014
PRODI : TEKNIK KIMIA “REGULER”
Ujian Tengah Semester Aplikom II
SOAL 3
Debug the code which is supposed to set up the function f(x) =
x3 cos(x + 1) on the grid x = 0 to 3 in steps of 0.1 and give the value of the function at x = 2 and
x=3
Jawaban :
>> x= 0:0.1:3;
f=x.^3.*cos(x+1);
%=2
f(2)

ans =

4.5360e-04

>> %=3
>> f(3)

ans =

0.0029

>> f(end)

ans =

-17.6484
NAMA : SITI NUR QORI’AH
NIM : 1901014
PRODI : TEKNIK KIMIA “REGULER”
Ujian Tengah Semester Aplikom II
SOAL 4
To plot the quadratic x2 +7x−3 from x equals −3 to 3 in steps
of 0.2
Jawaban :
>> x= (-3:0.2:3);
c= [1 7 -3];
y= polyval(c,x);
plot (x,y)

30

25

20

15

10

-5

-10

-15
-3 -2 -1 0 1 2 3
NAMA : SITI NUR QORI’AH
NIM : 1901014
PRODI : TEKNIK KIMIA “REGULER”
Ujian Tengah Semester Aplikom II
SOAL 5
Debug the code which is supposed to plot the polynomial x4 −1 between x = −2 and x = 2 using
20 points.
Jawaban:
x= linspace(-2,2,20);
c= [1 0 0 0 -1];
y= polyval (c,x);
plot (x,y)

16

14

12

10

-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2

You might also like