1.
[1 0 0
1 1 1
1 2/3 4/9 ]
[x0,x1,x2]'
[1 0 0.5]'
find x1 x2 x3
Correct Answer
A. 1 - 1/4 -3/4
2.
Function f=new4(x)
f=x.^3-4*x+3;
end
Apply the following in commands windows and find the results
feval(@new4,[-3 -2 -1 0 ]
Correct Answer
A. -12 3 6 3
Explanation
The given code defines a function called "new4" which takes an input "x" and returns the value of x^3 - 4x + 3. The "feval" function is then used to evaluate the "new4" function for the input values [-3, -2, -1, 0]. The results of these evaluations are -12, 3, 6, and 3 respectively.
3.
Find the results of the following series
E=1+1/2!+1/3!+1/4!+1/5! take x=2:5
5! is equal 5*4*3*2*1
Correct Answer
A. 1.7167
Explanation
The given series is a sum of reciprocals of factorials. The factorial of a number is the product of all positive integers less than or equal to that number. In this case, the factorial of 5 is 5 * 4 * 3 * 2 * 1 = 120.
By substituting x=2:5 into the series, we get:
E = 1 + 1/2! + 1/3! + 1/4! + 1/5!
= 1 + 1/2 + 1/6 + 1/24 + 1/120
= 1 + 0.5 + 0.1667 + 0.0417 + 0.0083
= 1.7167
Therefore, the correct answer is 1.7167.
4.
Function f=new(x)
f=x.^3-4*x+3; end
Apply the following in commands windows and find the results
fzero(@new,[-3 -2 ]
Correct Answer
E. -2.4567
Explanation
The answer -2.4567 is obtained by applying the fzero function to the function "new" with an initial interval of [-3 -2]. The fzero function is used to find the root of a given function within a specified interval. In this case, the function "new" is a cubic function defined as f(x) = x^3 - 4x + 3. By applying the fzero function, it is determined that the root of this function within the interval [-3 -2] is approximately -2.4567.
5.
In polynomials find [x1 x2 x3 ]from the following equations
X1+x2+x3=6
2x1+x2+x3=7
Correct Answer
A. [1.000 5.000]'
6.
Solve the following equation dy/dx=x^2+y^2
Initial values y(0) =1 , x=[0 1]
n=10
xn= x0+ n h
find y(0.4)
use Euler method
Correct Answer
C. 1.573
Explanation
Using the Euler method, we can approximate the value of y(0.4) by iteratively calculating the slope at each step and updating the y-value. Starting with the initial value y(0) = 1, we can calculate the slope at x = 0 using the given equation dy/dx = x^2 + y^2. Plugging in x = 0 and y = 1, we get dy/dx = 0^2 + 1^2 = 1.
Using this slope, we can calculate the approximate value of y at x = 0.1 by adding the product of the slope and the step size (h) to the previous value of y. Continuing this process for the given number of steps (n = 10) and using the step size (h = 0.1), we can find the approximate value of y at x = 0.4.
After performing the calculations, the approximate value of y(0.4) is found to be 1.573, which matches the given answer.
7.
In Runge-Kutta method
k2=
Correct Answer
B. K2=hf(xn+h/2,yn+k1/2)
Explanation
In the Runge-Kutta method, k2 is calculated by evaluating the derivative of the function at the midpoint of the interval, using the value of k1 divided by 2. This is represented by the equation k2 = hf(xn+h/2, yn+k1/2). This approach helps to improve the accuracy of the approximation by taking into account the average slope over the interval.
8.
Solve the following equation
dy/dx=x^2+y^2
Initial values y(0)=1 x=[0 1]
h=0.05
xn= x0+ n h
find y(0.4)
use Euler method
Correct Answer
B. 1.627
Explanation
Using the Euler method, we can approximate the value of y(0.4) by iteratively calculating the values of y at each step. Starting with y(0) = 1, we can calculate y(0.05) using the equation dy/dx = x^2 + y^2. Plugging in x = 0 and y = 1, we get dy/dx = 0^2 + 1^2 = 1. Multiplying this by the step size h = 0.05, we get dy = 0.05. Adding this to the initial value of y, we get y(0.05) = 1 + 0.05 = 1.05. We repeat this process for each step until we reach x = 0.4, and the approximate value of y(0.4) using the Euler method is 1.627.
9.
Approximate the area under the curve y=2^x between x=−1 and x=3 using the Trapezoidal Rule with n=4 subintervals.
rule
Tn=Δx/2[f(x0)+2f(x1)+2f(x2)+2f(x3)+f(xn)].
Correct Answer
C. Tn=11.25
Explanation
The Trapezoidal Rule is a method used to approximate the area under a curve by dividing the interval into smaller subintervals and approximating each subinterval with a trapezoid. The formula for the Trapezoidal Rule is given as Tn = Î”x/2[f(x0) + 2f(x1) + 2f(x2) + 2f(x3) + f(xn)], where Î”x is the width of each subinterval and f(xi) represents the value of the function at each subinterval. In this case, the Trapezoidal Rule with n=4 subintervals was used to approximate the area under the curve y=2^x between x=-1 and x=3, resulting in Tn=11.25.
10.
Nsteps= in Euler method
Correct Answer
E. (xn-x0)/(h)+1
Explanation
The given expression, (xn-x0)/(h)+1, represents the number of steps in Euler's method. In Euler's method, the number of steps is determined by the difference between the final and initial values (xn-x0), divided by the step size (h), and then adding 1. This is because each step in Euler's method approximates the solution at a specific point, and the total number of steps is determined by dividing the interval between the initial and final values by the step size, and then adding 1 to account for the initial value. Therefore, (xn-x0)/(h)+1 correctly represents the number of steps in Euler's method.
11.
X = linspace (0 ,2*pi ,41);
y = tan( x );
plot (x , y);
Correct Answer
D. Option 4
Explanation
The given code snippet generates a plot of the tangent function for values of x ranging from 0 to 2*pi. The plot command is used to create the graph. Therefore, the correct answer is Option 4, which indicates that the code will plot the tangent function.
12.
What is the function of @
Correct Answer
D. To create handle of a function
Explanation
The "@" symbol in programming languages, such as in Python, is used to create a handle or reference to a function. It allows you to pass functions as arguments, store them in variables, or return them as values. This is commonly used in scenarios where you want to pass a function as an argument to another function or when you want to store a function in a variable for later use.
13.
To plot the following
function y = myfunc ( x )
y = 2* x .^2 - 3* x + 1;
end
Correct Answer
D. Fplot(@myfunc,[-2 2])
Explanation
The correct answer is fplot(@myfunc,[-2 2]). This is the correct answer because the fplot function is used to plot a function, and the @myfunc specifies the function to be plotted. The range of x values to be plotted is specified as [-2 2].
14.
Express the this function in matlab
f(x)=e^{x} +sin(5x)
Correct Answer
C. F=@(x)exp(x)+sin(5*x)
Explanation
The correct answer is f=@(x)exp(x)+sin(5*x). This is the correct way to express the given function in MATLAB. The "@" symbol indicates that it is an anonymous function, and the "exp(x)" represents the exponential function and "sin(5*x)" represents the sine function. The plus sign is used to add the two functions together.
15.
What is function of (;)
Correct Answer
A. It is a rows separator
Explanation
The semicolon (;) is used as a row separator in certain programming languages or data formats. It is commonly used to separate multiple statements or expressions within a single line of code. In this context, it helps to organize and structure the code by indicating the end of one row or statement and the beginning of the next. By using semicolons, developers can write more concise and readable code, especially when dealing with complex or lengthy statements.
16.
X1 + x2 = 2
4x1 + 5x2 = 10
Correct Answer
A. [0 2]
Explanation
The given system of equations can be written in matrix form as Ax = b, where A is the coefficient matrix, x is the variable matrix, and b is the constant matrix. The coefficient matrix A is [[1, 1], [4, 5]], the variable matrix x is [x1, x2], and the constant matrix b is [2, 10]. To find the solution x, we can use matrix algebra and solve for x by multiplying both sides of the equation by the inverse of A. The inverse of A exists because the determinant of A is not zero. The solution x will be [0, 2].
17.
To print a new line in fprintf functions
Correct Answer
C. \n
Explanation
The correct answer is "\n". In the fprintf function, "\n" is used to print a new line. It is a special character that represents the end of a line and causes the cursor to move to the beginning of the next line when printed.
18.
What are %4.2f means in fprintf function
Correct Answer
C. 21.01
Explanation
The %4.2f in the fprintf function is a format specifier that is used to print a floating-point number with a width of 4 characters and a precision of 2 decimal places. In the given answer, 21.01 is the number that would be printed using this format specifier.
19.
To add comments
Correct Answer
B. % comments
20.
We run this commands isnumeric(32) the results is
Correct Answer
B. 1
Explanation
The command "isnumeric(32)" is used to check if the given input, which is 32 in this case, is a numeric value. The result of this command is 1, which means that 32 is indeed a numeric value.