R Programming language
Write a function as: y=sin(x) and plot this function using two ways. The range is from [-pi, pi]. ( in R Programming language)
#THIS IS THE FUNCTION FOR CREATING A FUNCTION AS : Y=SIN (X)
y<- function(x)
{
sin(x)
}
#STORING ALL THE POINTS FROM THE RANGE [-PI , PI]
x=seq(-pi,pi,by=0.1)
plot(x,y(x))
#THE FOLLOWING IS THE OUTPUT FOR THE PLOT FUNCTION.
#SECOND METHOD FOR PLOTTING
#THIS IS THE FUNCTION FOR CREATING A FUNCTION AS : Y=SIN (X)
y<- function(x)
{
sin(x)
}
#STORING ALL THE POINTS FROM THE RANGE [-PI , PI]
x=seq(-pi,pi,by=0.1)
barplot(x,y(x))
#OUTPUT FOR THE ABOVE FUNCTION
R Programming language Write a function as: y=sin(x) and plot this function using two ways. The...
must be python programming. consider function f(x) = sin(x) in the range of 0to pi. create a python code to calculate f’ (derivative of f(x)) in this range and plot these points. calculate the error at all the discrete points. Please do not use Numpy you can use matplotlib
Question is two parts In R(Programming language). Define and write a function which takes one number as input and detects whether the number is even. Return TRUE if it is even, and FALSE otherwise. You need to first detect if the input is an integer; if not, return NA. Note 1: TRUE and FALSE are logical values, not strings! Note 2: No need to get user input from the console. Test your function using your_function_name(1), your_function_name(2), and your_function_name(1.5). Hint: What...
6. Plot the 3D surface and contour levels of the following function: z(x, y)cos(2y-x) sin(2x) such that-π x π and-r y < π [10 marks] 7. Create a 5 x 5 random matrix M6 with elements ranging from 10 to 33. Using indexing, define the following arrays: An array containing all elements of M6 that are greater than 3 and smaller 6 marks] An array containing all elements of M6 that are negative or between 29 and 33. 6 marks...
C program language Plot the function y = x4 - x2 over the range -1 .2 < x < +1 . 2 Choose the y-axis scale so that the function can be seen everywhere over this x-range and yet is not so small that details are hard to see.
Using the programming language Java or C++, Write a function that takes an integer as input. Return true if this integer is a palindrome integer; false otherwise;
Use an anonymous function instead of a function file that calculates y(x) = sin(2x)( 4x2 + 3 ). Plot it using fplot, x goes from -8 to 8. Use your function to print out the value of y for x = -1.25 and x = 1.25. Deliverables: Script with anonymous function Plot using fplot Command window output Step by Step Instructions: Copy your calling script from Problem 1 Change the name of the function to be LabFcAnonymous (or something similar)...
Programming Language: MATLAB Problem 3: (5 Points) Write a function with the header: function [R] -myNewtonRaphson (f, fp, x0, tol) which takes as input f: a function handle fp: a function handle to the derivative of f (note how I do it in the test case). x0: the initial guess of the root tol: a tolerance above which the algorithm will keep iterating. Tips: . Be sure to include an iteration counter which will stop the while-loop if the number...
Using the programming language Java: Write a function to find the longest common prefix string amongst an array of strings.
1. in Matlab, write a user-defined function, with two input (r,theta) , θ expressed in degrees) and two output arguments (X,Y). The inputs are a location on a polar coordinates corresponding to Cartesian plane expressed in rectangular coordinates. The picture below describes the problem. X, Y rcos θ Some formula that you may need: x = r * cos (theta * pi/180); y r * sin(theta * pi/180); Test your code for r=7, theta=55° and present your results.
To plot a figure of a function y=f(t) in an interval a and b in MATLAB, one should find n-1 points of t between a and b and then find the corresponding values to plot the figure. Below shows an example of a sin function in the range of 0 and 1 with 1000 increments, as well as the figure. >> t = 0:0.001:1; >> y = sin(2*pi*2*t); >> figure >> plot(t, y) 0 02 04 06 08 Demonstrate a...