Concept explainers
Explanation of Solution
Implementation of norm(v):
The norm() method takes the input parameter of “vec” to return the Euclidean norm of “vec” array of coordinates.
//Function definition
public static double norm(double[ ] vec)
{
/*Call the norm() by passing the “vec” and “2” and return the result of computed value. */
return norm(vec,2);
}
Explanation:
In norm() method,
- It takes the input parameter of “vec”.
- Call the norm() method by passing the “vec” and “2” and return the result of computed value of p-norm value of “vec” array of coordinates.
Implementation of norm(v, p):
The norm() method takes the input parameter of “vec” and “pow” to return the p-norm value of “vec” array of coordinates.
//Function definition
public static double norm(double[ ] vec, int pow)
{
//Declare the variables
int sum = 0;
double exp = 1.0/pow;
//Loop executes until from “i” to "vec"
for (double i : vec)
//Add the "sum" and the power of number
sum += Math.pow(i,pow);
//Return the return
return Math.pow(sum, exp);
}
Explanation:
In norm() method,
- It takes the input parameter of “vec” and “pow”.
- Loop executes until the “vec” to add the sum and power of input.
- Return the computed p-norm value of “vec” array of coordinates.
Complete Program:
/**********************************************************
* Program demonstrates how to determine the Euclidean norm*
* for two-dimensional
Want to see the full answer?
Check out a sample textbook solutionChapter 1 Solutions
Data Structures and Algorithms in Java
- use my ID : 201909010 SOLVE ALL BY matlab Consider the graphs of the functions f(x) = m - 1x and g(x) = 2x² — n where m and n are the maximum and mean values of the digits in your student-ID number. a) Create a vector v whose elements are the digits of your student-ID number. b) Create a variable m and assign the maximum digit in v to it. Create a variable n and assign the mean value of the digits in v to it. d) Define the function f(x) and g(x) above as anonymous functions. Plot the graphs of f(x) and g(x) on the same figure using the MATLAB function ezplot. f) Find the exact values of the x-coordinates of the intersection points between the two graphs using the MATLAB function solve. g) Find the area bounded by the two graphs.arrow_forwardPls Use Python If there is a non-singular matrix P such as P-1AP=D , matrix A is called a diagonalizable matrix. A, n x n square matrix is diagonalizable if and only if matrix A has n linearly independent eigenvectors. In this case, the diagonal elements of the diagonal matrix D are the eigenvalues of the matrix A. A=({{1, -1, -1}, {1, 3, 1}, {-3, 1, -1}}) : 1 -1 -1 1 3 1 -3 1 -1 a)Write a program that calculates the eigenvalues and eigenvectors of matrix A using NumPy. b)Write the program that determines whether the D matrix is diagonal by calculating the D matrix, using NumPy. Ps: Please also explain step by step with " # "arrow_forwardThe vector x ∈ R N has L different entries. For example, L = 4 for x = [3,4,4,5,3,1,5,3]T . One can express x as x = S u, where u ∈ R L satisfies (u)i < (u)j if i < j and S is a matrix that contains only zeros and ones. Write the function repeated_entries, which takes x as input and returns S and u.arrow_forward
- This problem is on Computer Graphics and is based on the topic 'Perspective Projection'. Please provide a step-by-step solution to the problem and explain the steps. The solution must include the General purpose perspective projection matrix. Question: Let a 3D point (423, -423, 423) be projected on a projection plane. Given that the center of the projection plane is (0.0, 0.0, -423.0) and the coordinate of the COP is (4, 2, 3). Determine the coordinate of that 3D point on the projection plane using a general purpose perspective projection matrix.arrow_forwardSuppose we have a two-dimensional vector [ U₁ U₂]. Select all the translations that would occur on the vector from the operation [ u₁, U2 ]-[-7, -5] 2 O Shift up Shift down Shift right Shift left O No horizontal shift No vertical shiftarrow_forward| For any given vector x find the correct way to define the following function in MATLAB Vsin x f(x) = e* cos x 2 + cos x f = (x) exp(x) * cos(x) – sqrt(sin(x))/(2+ cos(x)) f = (x) exp(x).* cos(x) – sqrt(sin(x))/(2 + cos(x)) f = (x) e*.* cos(x) – sqrt(sin(x)). /(2 + cos(x)) f = (x) exp(x).* cos(x) – sqrt(sin(x)). /(2 + cos(x)) f : = inline (' (exp(x).* cos(x) – sqrt(sin(x)))/(2 + cos(x))', 'x')arrow_forward
- The interval between the points in the vector rt=[1:0.4:5] isarrow_forwardComputer Science Compute the DFT of the vector x = [0, 1, 2, 3, 4, 5] by running FFT(x) using any software tool such as matlab.arrow_forwardThe compass gradient operators of size 3x3 are designed to measure gradients of edges oriented in eight directions: E, NE, N, NW, W, SW, S, and SE. i) Give the form of these eight operators using coefficients valued 0, 1 or – 1. ii) Specify the gradient vector direction of each mask, keeping in mind that the gradient direction is orthogonal to the edge direction.arrow_forward
- Use the function to find the image of v and the preimage of w. T(V1, V2, V3) = (4v2 - V1, 4V1 + 5v2), v = (1, -2, -3), w = (3, 9) (a) the image of v (b) the preimage of w (If the vector has an infinite number of solutions, give your answer in terms of the parameter t.)arrow_forwardLet u, v and w be three n-dimensional column vectors. We would like to compute r = uvw, which is also an n-dimensional vector. Justify your answer on which of the following sequence of computation is better: (uv)w_or_u(vw)?arrow_forwardjupyter nootebook python with julia 1: Modify your models and coding of Chebyshev center and building a house to get the right anwsers. # Given matrix A and vector b A = [2 -1 2; -1 2 4; 1 2 -2; -1 0 0; 0 -1 0; 0 0 -1]b = [2; 16; 8; 0; 0; 0]arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrOperations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole