MATLAB Multiple Choice Questions on “Differentiation – 1”.
1. Which rule does MATLAB use while differentiating a set of functions?
a) u-v rule
b) by parts
c) no pre-defined rule
d) not possible
Answer: a
Clarification: If we give an argument within our command diff() which is a product of multiple functions or division of two functions; we will get the result that will be generated according to the u-v rule. This makes MATLAB very versatile for the applications concerning differentiation.
2. There is no difference between a difference equation and a differential equation.
a) True
b) False
Answer: b
Clarification: There are many differences between a difference equation and a differential equation. But the most important would be that a difference equation takes finite steps of changes of our changing variable while a differential equation takes an infinitesimal change in our changing variable.
3. For the existence of the nth (n is varying from 1 to until the derivative is becoming 0) derivative of an equation, the equation should have __________
a) Initial values
b) At least one independent variable
c) At least one dependent variable
d) No such condition
Answer: b
Clarification: Derivatives are calculated with respect to a change in an independent variable. Hence for deriving a derivative- the equation should have at least one independent variable so that we can find the derivative with respect to a change in that independent variable.
4. What will be the output of the following code?
syms x;diff(sin(x)x2)
a) (2*x)/sin(x) – (x2*cos(x))/sin(x)2
b) cos(x)/x2 – (2*sin(x))/x3
c) x2*cos(x) + 2*x*sin(x)
d) Error
Answer: a
Clarification: We observe that sin(x)x2 has a back slash. This, in MATLAB, implies that x2 is divided by sin(x). Hence the answer is (2*x)/sin(x) – (x2*cos(x))/sin(x)2. If it would have been a front slash, the answer would have been cos(x)/x2 – (2*sin(x))/x3. If there was a ‘*’ sign, the answer would have been ‘x2*cos(x) + 2*x*sin(x)’.
5. What is the data type of y?
y=diff(x2*cos(x) + 2*x*sin(x))
a) Symbolic
b) Double
c) Array
d) Symbolic Array
Answer: d
Clarification: Every element saved in the workspace is stored as an array. The class of the array will be symbolic for y since we haven’t specified a value for x. If we give a value of x, y will be stored as Double.
6. The output for diff(p2,q) is _______
a) 0
b) 2*p
c) 2 dp/dq
d) Error
Answer: a
Clarification: We are differentiating the function ‘p2’ with respect to q. Hence the value will be 0. The 2nd argument in the diff() command is the variable, with respect to which- we differentiate our function.
Output: 2*p
7. What does the following code do?
syms m,y,x,c; y=mx+c; diff(y)
a) Calculate m
b) Calculate slope
c) Error
d) Calculate divergence
Answer: c
Clarification: While using syms, we can’t instantiate multiple symbolic variables using a comma. We will have to enter them with space in between. Hence MATLAB returns an error. If we remove the comma, the code will calculate the slope of ‘y=mx+c’.
8. What is the nature of ode45 solver?
a) 2nd ordered R-K solver
b) 4th ordered R-K solver
c) 1st order R-K solver
d) Adams solver
