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 vectors...
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_forwardQuestionarrow_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
- Solve the following problem in Pythonarrow_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_forwardsolve this question in pythonarrow_forward
- Modify the Chebyshev center coding with julia in a simple style using vectors, matrices and for loops # Given matrix A and vector bA = [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] A small sample:Let t_(l),t_(o),t_(m),t_(n),t_(t),t_(s) be starttimes of the associated tasks.Now use the graph to write thedependency constraints:Tasks o,m, and n can't start until task I is finished, and task Itakes 3 days to finish. So the constraints are:t_(l)+3<=t_(o),t_(l)+3<=t_(m),t_(l)+3<=t_(n)Task t can't start until tasks m and n are finished. Therefore:t_(m)+1<=t_(t),t_(n)+2<=t_(t),Task s can't start until tasks o and t are finished. Therefore:t_(o)+3<=t_(s),t_(t)+3<=t_(s)arrow_forwardComputer sciencearrow_forwardPython code for this one, thanksarrow_forward
- Let 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_forwardComputational Mathmatics. Please answer a, b and c.arrow_forwardProblem 5. Let u = g – g(-), where g-) = (g-1, 90, 91,...,gr-1). Interpret the physical meaning of the vector u.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