Q3: Complete the code that returns the value of f(x), which has the value 1 inside the range -1 < x<1 otherwise it is the value 0. 1, xE[-1,1] 1 0, otherwise f(x) = ]: M # complete the function to return the value of f(x) given x. # return as the value called variable "fval" def function_f(x): # your code here return fval ]: N ## Don 't write any code in this box 1: N ## Don't write any code in this box ]: ## Don 't write any code in this box ]: I ## Don't write any code in this box 1: ## Don't write any code in this box 1: ## Don't write any code in this box Q4: Complete the function that adds 3 matrices together. The matrices will be numpy type and of the same dimension of 3 x 3. There are several ways to do this, any correct answer will be accepted. I # add the matrices a, b,c together, these willL have been passed to the function # as standard numpy matrices. Rememeber if you are unsure, just print the ]: # elements to see how to access the matrix values. # there are several ways to do this, anyway you do this is fine import numpy as np def add_matrices (a, b,c): # initiate the matrix based on the assumption that the matrix is 3x3. matrix = np.zeros ([3,3]) # your code here return matrix

Calculus: Early Transcendentals
8th Edition
ISBN:9781285741550
Author:James Stewart
Publisher:James Stewart
Chapter1: Functions And Models
Section: Chapter Questions
Problem 1RCC: (a) What is a function? What are its domain and range? (b) What is the graph of a function? (c) How...
icon
Related questions
Question

I need help with these 2 questions

Q3:
Complete the code that returns the value of f(x), which has the value 1 inside the range -1 <x<1 otherwise it is the value 0.
1, xE[-1,1]
0, otherwise
f(x) =
In [ ]:
M # complete the function to return the value of f(x) given x.
# return as the value called variable "fval"
def function_f(x):
# your code here
return fval
In [ ]:
I ## Don 't write any code in this box
In [ ]:
N ## Don't write any code in this box
In [ ]:
I ## Don 't write any code in this box
In [ ]:
N ## Don't write any code in this box
In [ ]:
N ## Don 't write any code in this box
In [ ]:
H ## Don 't write any code in this box
Q4:
Complete the function that adds 3 matrices together. The matrices will be numpy type and of the same dimension of 3 x 3. There are several ways to do this,
any correct answer will be accepted.
In [ ]: # add the matrices a,b,c together, these will have been passed to the function
# as standard numpy matrices. Rememeber if you are unsure, just print the
# elements to see how to access the matrix values.
# there are several ways to do this, anyway you do this is fine
import numpy as np
def add_matrices(a, b,c):
# initiate the matrix based on the assumption that the matrix is 3x3.
matrix = np. zeros ([3,3])
# your code here
return matrix
Transcribed Image Text:Q3: Complete the code that returns the value of f(x), which has the value 1 inside the range -1 <x<1 otherwise it is the value 0. 1, xE[-1,1] 0, otherwise f(x) = In [ ]: M # complete the function to return the value of f(x) given x. # return as the value called variable "fval" def function_f(x): # your code here return fval In [ ]: I ## Don 't write any code in this box In [ ]: N ## Don't write any code in this box In [ ]: I ## Don 't write any code in this box In [ ]: N ## Don't write any code in this box In [ ]: N ## Don 't write any code in this box In [ ]: H ## Don 't write any code in this box Q4: Complete the function that adds 3 matrices together. The matrices will be numpy type and of the same dimension of 3 x 3. There are several ways to do this, any correct answer will be accepted. In [ ]: # add the matrices a,b,c together, these will have been passed to the function # as standard numpy matrices. Rememeber if you are unsure, just print the # elements to see how to access the matrix values. # there are several ways to do this, anyway you do this is fine import numpy as np def add_matrices(a, b,c): # initiate the matrix based on the assumption that the matrix is 3x3. matrix = np. zeros ([3,3]) # your code here return matrix
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Calculus: Early Transcendentals
Calculus: Early Transcendentals
Calculus
ISBN:
9781285741550
Author:
James Stewart
Publisher:
Cengage Learning
Thomas' Calculus (14th Edition)
Thomas' Calculus (14th Edition)
Calculus
ISBN:
9780134438986
Author:
Joel R. Hass, Christopher E. Heil, Maurice D. Weir
Publisher:
PEARSON
Calculus: Early Transcendentals (3rd Edition)
Calculus: Early Transcendentals (3rd Edition)
Calculus
ISBN:
9780134763644
Author:
William L. Briggs, Lyle Cochran, Bernard Gillett, Eric Schulz
Publisher:
PEARSON
Calculus: Early Transcendentals
Calculus: Early Transcendentals
Calculus
ISBN:
9781319050740
Author:
Jon Rogawski, Colin Adams, Robert Franzosa
Publisher:
W. H. Freeman
Precalculus
Precalculus
Calculus
ISBN:
9780135189405
Author:
Michael Sullivan
Publisher:
PEARSON
Calculus: Early Transcendental Functions
Calculus: Early Transcendental Functions
Calculus
ISBN:
9781337552516
Author:
Ron Larson, Bruce H. Edwards
Publisher:
Cengage Learning