Evaluate the function: f(x,y) = xcos(x) ysin(y) with 2 variables over a range of
ID: 3675662 • Letter: E
Question
Evaluate the function: f(x,y) = xcos(x) ysin(y) with 2 variables over a range of input values, using one- and two-dimensional arrays. Then, calculate the X and Y vectors based on user input. For any range of floating point numbers ranging from a minimum to a maximum in N steps of delta each, the four quantities are related by: nSteps = (max - min)/delta + 1. Use for loops to go through a range of floating point values. Once nXsteps and nYsteps is known, allocate the vectors to the needed sizes. Code is written in c++.
Explanation / Answer
To plot the graph of a function, you need to take the following steps
Define x, by specifying the range of values for the variable x, for which the function is to be plotted
Define the function, y = f(x)
Call the plot command, as plot(x, y)
Following example would demonstrate the concept. Let us plot the simple function y = x for the range of values for x from 0 to 100, with an increment of 5.
Create a script file and type the following code
Example
Let us draw the graph of two polynomials
f(x) = 3x4 + 2x3+ 7x2 + 2x + 9 and
g(x) = 5x3 + 9x + 2
Create a script file and type the following code
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.