13. Write a function slope (xl, yl, x2, y2) that returns the slope of the line through the points (x1,yl) and (x2, y2). Be sure your implementation of slope can pass the following tests test (slope (5, 3, 4, 2) test (slope (1, 2, 3, 2)- 0,0). Lest (slope(1, 2, 3, 3)= 0.5) test (slope (2, 4, 1, 2) 2.0) 1,01 Then use a call to slope in a new functlon named intercept (x1, yl, x2, y2) that returns the y-intercept of the line through the points (x1, yl) and (x2, y2). Test (intereept (1, 6, 2, 12) 30 test (1ntercept (4, 1, 12,8) 5.0) 14 Write a function çalled is even (n) that takes an integer as an argument and returns True if the arpument is an even numbe
Q: Write a definition for a void-function that has two int value parameters and outputs to the screen…
A: Solution: Given: Two int value parameters and outputs to screen the product of these arguments.…
Q: Create a function that takes numbers $b and $m as arguments and returns the derivative of the…
A: In this problem we need to work on the PHP programming lanaguage and createa progrma for the…
Q: Write a program with two functions and a main(), each having at least two parameters. The functions…
A: Initializing 2 functions and exchanging information between them.
Q: Write a function that receives the left, bottom, right and top coordinates of two rectangles, and…
A: Given : Rectangles are given as follows:intersection(l1,b1,r1,t1,l2,b2,r2,t2)where,l1 -> left of…
Q: Write a function pythagorean that takes three integers $a$, $b$, $c$, and returns the boolean whose…
A: I have given an answer in step 2.
Q: Write a function "DivRemain" that will return both the dividend and the remainder from dividing two…
A: #include <stdio.h> void DivRemain(int one , int two){ int Dividend =0; int Remainder =0;…
Q: Given that a function receives three parameters a, b, c, of type double, write some code, to be…
A: Providing the code in c++ as no coding language is mentioned: #include <iostream>using…
Q: Write a function to simulate coin tossing, the function will use rand function that gives an output…
A: Source code: //toss() function to get the result of tossing a coin #include<stdio.h>int…
Q: 2. Write a program that returns the minimum of a single-variable function g(x) in a given region [a,…
A: Step 1 INTRODUCTION: Python is a strong general-purpose and high-level programming language. It is…
Q: Write the definition of a function dashedLine, with one parameter, an int. If the parameter is…
A: Solution of the given question is:-
Q: Write a program that uses the function isPalindrome given in Example 6-6 (Palindrome). Test your…
A: A number that is the same number in reverse is referred to as a palindrome number. 3553, 12321, etc.…
Q: Write the definition of a function absoluteValue, that receives an integer parameter and returns the…
A: As given, I need to write a C++ program having a function called absoluteValue that takes an integer…
Q: Write a function in C++ to take input an integer parameter n and return whether the number is a…
A: Write a function in C++ to take input an integer parameter n and return whether the number is a…
Q: Given two overloaded functions below. int f(int &a, int b) { int c = a + b; a = a+1; b = b+1; return…
A: Consider the first function: int f(int &a,int b) { int c=a+b; a=a+1; b=b+1; return c; }
Q: (13.)Write a function slope(x1, y1, x2, y2) that returns the slope of the line through the points…
A: def slope(x1,y1,x2,y2): return (y2-y1)/(x2-x1)…
Q: Given the code segment below, what should be the data type of the formal parameter in the function…
A: In this question, we are asked to write the correct data type that needs to be passed in the…
Q: Write a function is_valid_triangle() that gets three parameters that are the lengths of edges of a…
A: Declare an define the function is_valid_triangle() with parameters a,b,c: Implement the above…
Q: Write a c++ program that takes a date in the following format: December 24th, 2021 and extracts the…
A: The code for c++
Q: Write a program that has a class triangle with an overloaded function Area(). If two sides are…
A: Function Overloading: It is also know as method overloading. The function is said to be…
Q: Write program in python with a function occupy(n), which shows how birds are going to occupy n…
A: Given that, Writing a program in python with a function occupy(n), which shows how birds are going…
Q: 2. Write a Java program to find out the greatest common divisor of two input values using a…
A: The above question is solved in step 2 :-
Q: Design a class ProblemSolution to overload a function solution. Write a function int…
A: import java.util.*; public class ProblemSolution{ static int solution(int N, char CH) { //…
Q: Write a value-returning function, isVowel, that returns the value true if a given character is a…
A: import java.util.*;public class Main { public static boolean isVowel(char ch){ if(ch…
Q: Write a program that uses the function isPalindrome given in Example 6-6 (Palindrome). Test your…
A: Program Plan: Include all the necessary header files define a method isPalindrome() this method…
Q: Write a function which takes one parameter int num, and prints out a countdown timer with minutes…
A: Create a function that prints the countdown timer. The given signature of the function is: void…
Q: Write the function that takes three dimensions of a brick: height(a), width(b) and depth(c) and…
A: Find Your Code below
Q: Write a function that gets two integer parameters between 1 and 100 and prints their common factors…
A: Program #include <iostream> using namespace std; // function to calculate the common factor of…
Q: Write a c++ program that takes a date in the following format: December 24th, 2021 and extracts the…
A: The program is written in c++. Here, December 24th, 2021 and extracts the day, month, and year as 3…
Q: ANSWER IN C PROGRAMMING- write a function called 'letter_grade' that has a type int input parameter…
A: The gradep and just_missedp output parameters will be calculated using 'if' and 'else' statement…
Q: Write a program in c++ to insert a 9-digit variable and make 9-digit commas In a function alone, and…
A: /* * Prompt user for two integers and print their sum, difference, product and quotient *…
Q: Implement the following functions with PLA a) F1(A,B,C,D) = Em(0,2,7,10)+ Ed(12,15) b) F2(A,B,C,D) =…
A: To implement the function with PLA.
Q: The correct prototype for the following function heading is void F1(int &p1, double &p2, bool &p3) A…
A: Answer is A
Q: Write the definition of a function isSenior,that receives an integer parameter and returns true if…
A: #note no programming language is mentioned so i was solved using c++ #include<iostream>using…
Q: Complete the given CPP function definition and run it for a test case. void swapString(string &str,…
A: Complete the given CPP function definition and run it for a test case. About the given function: The…
Q: Write a function named sumDigits which takes three parameters: f, t and x. sumDigits, then, finds…
A: function sumDigits(f,t,x): Start for i in f to t follow steps 3 to 10 Number = i initialize Sum = 0…
Q: Write a function that receives the left, bottom, right and top coordinates of two rectangles, and…
A: the answer is an given below ;
Q: What is the output of the following function: =IF (5 >13, “WhAT”,IF( 13<=6, “iS”, IF( 5>=…
A: =IF (5 >13, “WhAT”,IF( 13<=6, “iS”, IF( 5>= 2^2, “GOiNG”, “oN!”))) This function will…
Q: Consider the code in the clear_one function. void clear_one (int m[N] [N][N]) int i, j, k; for (i =…
A: clear_one function takes argument a three dimensional matrix m of size nXnXn
Q: Write a function that receives the left, bottom, right and top coordinates of two rectangles, and…
A: Program for given condition :- def intersection(l1, b1, r1, t1, l2, b2, r2, t2): """ Function…
Q: The correct prototype for the following function heading is void F1(int &p1. double &p2. bool &p3)…
A: Function prototype:- 1) A function prototype in a simple words can be defined as a way to state a…
Q: In C, write a function that gets two ints a and b. If a>b the function returns a^3 + b^2, and…
A: /* C program to write a function that gets two ints a and b. If a>b the function returns a^3 +…
Q: Question 12 The correct prototype for the following function heading is void F1(int &p1, double &p2,…
A: Lets see the solution.
Q: According to the given question, we have to create the test-cases based on the above-given function…
A: The python files for test cases and test driver along with the class files are given below. There…
Q: function [P, A] = rect(L, W) P= 2 (L+ W); A=L W; end Above function is defined to find perimeter and…
A: The function is rect and it is accepting two parameters length and width and returns perimeter and…
Q: Write the definition of a function isEven, that receives an integer parameter and returns true if…
A: Definition of the Function isEven is:- bool isEven(int x) { if(x%2==0){…
Q: Trace the function f as demonstrated in class for the function call f(3, 2): void f(int x, int y) {…
A: Here in this question we have given a c++ code segment and we have asked to trace the following code…
Q: /* Write a function `coinProblem` that takes * 3 arguments: N, M and K; and solves following *…
A: PROGRAM EXPLANATION: Include the header file. Define a function coin problem(), this function will…
Q: Consider the code in the clear_one function. void clear_one (int m[N] [N] [N]} { int i, j, k; for (i…
A: Solution : The given function
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
- In Python, write a function that produces plots of statistical power versus sample size for simple linear regression. The function should be of the form LinRegPower(N,B,A,sd,nrep), where N is a vector/list of sample sizes, B is the true slope, A is the true intercept, sd is the true standard deviation of the residuals, and nrep is the number of simulation replicates. The function should conduct simulations and then produce a plot of statistical power versus the sample sizes in N for the hypothesis test of whether the slope is different than zero. B and A can be vectors/lists of equal length. In this case, the plot should have separate lines for each pair of A and B values (A[1] with B[1], A[2] with B[2], etc). The function should produce an informative error message if A and B are not the same length. It should also give an informative error message if N only has a single value. Demonstrate your function with some sample plots. Find some cases where power varies from close to zero to…You are to create a well-formed Python recursive function (i.e, there must be a stopping/base case and the recursive case must present a smaller problem), along with a call to that function. You will then trace that function, showing how memory is used and provide any and all output. You then need to present a relationship, whose domain is some subset of the integers. Finally, you need to provide a prove that the relationship holds over the entire domain by using detailed Mathematical Induction prove. 1. You are to create a well-formed Python recursive function (i.e, there must be a stopping/base case and the recursive case must present a smaller problem), along with a call to that function. 2. Trace your function and call. Remember that you must keep track of memory for each function call and provide output. 3. Present a relationship with the domain some subset of the integers that is to be proven via Mathematical Induction. 4. Prove your relationship with the domain some subset…Create a curve that uses a quadratic parametric approach with three interpolated control points. The equations which describe the curve are: $$f_x(u) = c_0 u^2 + c_1 u + c_2 $$ and $$f_y(u) = c_3 u^2 + c_4 u + c_5 $$ where $u$ ranges from 0.0 to 1.0. The first control point $$p_0$$ is for $u=0$, the second $p_1$ for $u=0.5$, and the third for $p_2$ and at $u=1.0$. Modify the code to implement your solution. It is sufficient for this task to get the program working with three control points, but you are most welcome to attempt a solution that works on four or more. Code: import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; import java.awt.geom.Path2D; import java.awt.geom.Point2D; import javax.swing.JFrame; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; public class DotToDotDemo implements Runnable { /** * DotToDotDemo - A demo which draws dots between points to form a curve. * Eric McCreath 2015, 2019 - GPL * Modified by Matthew Aitchison 2022. */ JFrame…
- In Kotlin A. Write a function lengthGreaterThan() with an expression body that takes a String s and an Int n and returns true if the String is at least n characters long. Then revise the function so that it can accept null values. If it receives null as the parameter, it should return false. B. Write a recursive function with an expression body that takes a list of nullable Strings and and Int an returns a list of just the Strings from the original list for which the function you wrote in the first part returns true C. Get the same result as in part B by using filter()(Program) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters, such as zerocount, onecount, twocount, and so forth, to 0. Then generate a large number of pseudorandom integers between 0 and 9. Each time 0 occurs, increment zerocount; when 1 occurs, increment onecount; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of time they occurred.Write a Matlab function that will: read in the spreadsheet file, accept two textual/string arguments: first metric abbreviation/acronym (for example GP) from the list above, Second metric abbreviation/acronym (for example 3P%) from the list above, finds the player (A) who has the highest/maximum value of the FIRST METRIC (if there is more than one with that value, pick the first one - lowest row number) and stores his name and corresponding FIRST METRIC value, finds the player (B) who has the lowest/minimum value of the FIRST METRIC (if there is more than one with that value, pick the first one - lowest row number) and stores his name and corresponding FIRST METRIC value, computes FIRST METRIC average for all players, finds SECOND METRIC value for both players found above, computes SECOND METRIC average for all players,
- SUCCESSIVE-OVER-RELAXATION Method TROUBLESHOOTING: Fix the errors in the code below and run the script with your modified code and screenshot your output and codes with answer function [x,numIter,omega] = gaussSeidel(func,x,maxIter,epsilon) % Solves Ax = b by Gauss-Seidel method with relaxation. % USAGE: [x,numIter,omega] = gaussSeidel(func,x,maxIter,epsilon) % INPUT: % func = handle of function that returns improved x using % x = starting solution vector % maxIter = allowable number of iterations (default is 500) % epsilon = error tolerance (default is 1.0e-9) % OUTPUT: % x = solution vector % numIter = number of iterations carried out % omega = computed relaxation factor if nargin < 4; epsilon = 1.0e-9; end if nargin < 3; maxIter = 500; end k = 10; p = 1; omega = 1; for numIter = 1:maxIter xOld = x; x = feval(func,x,omega); dx = sqrt(dot(x - xOld,x - xOld)); if dx < epsilon; return; end if numIter == k; dx1 = dx; end if numIter == k + p omega = 2/(1 + sqrt(1 -…In kotlin, write an isPyth(a,b,c) function with an expression body that takes three Doubles as arguments and returns true if they are a Pythagorean triple, otherwise returns false. use Math.pow(base, exponent), where both base and exponent are Doubles. Double has an .equals() method; use that, not ==An object leaves point P1 with coordinates (−1,0) and travels with velocity v1=1 in a straight line to point P2 with coordinates (0,h) . It then travels with velocity v2=2 in a straight line from P2 to point P3 with coordinates (x , y ). Given x and y values there will be some optimal h value that minimizes the total travel time. Write a program in Scilab containing a function in the form function u = h(x,y) [your code goes here] endfunction u = h(1,2); disp(u); that calculates this optimal h value (to an accuracy of about 10^−6 ) given x and y values as arguments. Your function must work for any positive values of x and y.
- I need a Clark and Wright Savings Algorithm in Python. Are there any templates already? I have the following distance matrix given: [0, 10, 5, 9999, 9999, 9999, 9999], [10, 0, 5, 15, 20, 9999, 9999], [5, 5, 0, 10, 9999, 9999, 9999], [9999, 15, 10, 0, 15, 20, 15], [9999, 20, 9999, 15, 0, 5, 9999], [9999, 9999, 9999, 20, 5, 0, 20], [9999, 9999, 9999, 15, 9999, 20, 0]Consider the function, f(n), defined by the following code int f(int n) { int r = 0; if ( n % 2 == 0 ) return 1; // when n is even while ( n > 1 ) { n = n – 3; r++; } return r; } From the definitions of big-Theta and little-oh: Prove or disprove that f(n) is Θ ( n ) 2. Prove or disprove that f(n) is o ( n^2 ) ( note: function f(n) as defined by the code, that is, the return value, and is not asking about the runtime of the code.)A triple (x, y, z) of positive integers is pythagorean if x2 + y2 = z2. Using the functions studied in class, define a function pyth which returns the list of all pythagorean triples whose components are at most a given limit. For example, function call pyth(10) should return [(3, 4, 5), (4, 3, 5), (6, 8, 10), (8, 6, 10)]. [Hint: One way to do this is to construct a list of all triples (use unfold to create a list of integers, and then a for-comprehension to create a list of all triples), and then select the pythagorean ones. def unfold[A, S](z: S)(f: S => Option[(A, S)]): LazyList[A] = f(z) match { case Some((h, s)) => h #:: unfold(s)(f) case None => LazyList() } code in scala