USING SCILAB Sorry I tried to rotate the pic Thanks in adva
USING SCILAB :
Sorry I tried to rotate the pic
Thanks in advance !
loads/HW Chapter 3.pdf 3.4 Homework: Programming, Functions and Scripts 3.4.1 Create functions toevaluate the following functions (select meaningful names) 2. y(x) 3. x) cos(x and check the functions for 0,1 3.4.2 create a function to change radians degrees y(x) 180 and check the to x function for x TI2,TI3 3.4.3 Create a function to compute the area of the triangle hb and check the b) function for h 2, 10 3.4.4 The harmonic series I is divergent. Write a script file to s the series 100 n-I 1000 00000 3.4.5 The eries S es comergent, Fna vs for dulerent values of n: 2, 1000 n e 1000 100000 Divide the above sums by the value r. What is your conclusion?Solution
Sorry But I will be using Matlab, as I dont have Scilab available with me, but the script will be fairly similar.
%%%
function answer = cubic_polynomial(x)
answer = x^3 - x;
%%%
function ans = inverse_polynomial(x)
ans = 1/(1+x^2);
%%%
function ans = cosine_square(x)
ans = cos(x^2);
%%%
once u have saved all these three functions in three files, u can call each of them by the filenames u saved (the suggested names would be the function names given in the code, example : cubic_ploynomial(0.1) for problem 1a))
2) function ans = rad_to_deg(x)
ans = x*180/pi;
%%%
save it as rad_to_degree file and u can call using rad_to_deg(pi/2).
3) function ans = area(h,b)
ans = h*b/2;
4)a)
%%%
sum = 0;
for i = 1:100
sum = sum + 1/i;
end
%%%
4b) sum = 0;
for i = 1:1000
sum = sum+1/i;
end
%%%
5)
sum = 0;
for i = 1:100
sum = sum + 6/k^2;
end
as we keep changing the loop for 10000 and further we can see the values getting closer and closer
hence convergent, where as in earlier caes on 1/i, its divergent.

