Question

In: Computer Science

In python import numpy as np Given the array b = np.arange(-6, 4) compute and print...

In python

import numpy as np

Given the array b = np.arange(-6, 4) compute and print

1.) The array formed by \(bi^2 - 1\), where the \(bi\) are the elements of the array b.

2.) The array formed by multiplying b with the scalar 100.

3.)The array formed by 2.0 b i in reverse order. (Note: the base 2.0 must be a floating point number; for integer values a ValueError: Integers to negative integer powers are not allowed. is raised.)

4.) The array delta of length len(b)-1 that contains the differences between subsequence entries of \(bi^3\), namely \(\deltai = b{i+1}^3 - bi^3 \) with 0 ≤ i < N − 1 where N is the length of b. Print both delta.shape and delta.

Solutions

Expert Solution

import numpy as np

b = np.arange(-6, 4) # result : b = [-6 -5 -4 -3 -2 -1 0 1 2 3]

The array formed by \(bi^2 - 1\), where the \(bi\) are the elements of the array b.

result_array = []

for i in b:

result_array.append(i^2 - 1)

print(result_array)

The array formed by multiplying b with the scalar 100.

result_array = []

for i in b:

result_array.append(i*100)

print(result_array)

The array formed by 2.0 b i in reverse order.

def reverse(list):

return(element for element in reversed(list))

result_array = []

b = reverse(b)

for i in b:

result_array.append(b*2.0)

print(result_array)

The array delta of length len(b)-1 that contains the differences between subsequence entries of \(bi^3\), namely \(\deltai = b{i+1}^3 - bi^3 \) with 0 ≤ i < N − 1 where N is the length of b. Print both delta.shape and delta.

delta = []

result_array = []

for i in b:

result_array.append[i^3]

for i in range(len(b)-1):

delta.append(abs(result_array[i] - result_array[i+1]))

print(delta)

  


Related Solutions

Please I seek assistance Python Programing import os import numpy as np def generate_assignment_data(expected_grade_file_path, std_dev, output_file_path):...
Please I seek assistance Python Programing import os import numpy as np def generate_assignment_data(expected_grade_file_path, std_dev, output_file_path): """ Retrieve list of students and their expected grade from file, generate a sampled test grade for each student drawn from a Gaussian distribution defined by the student expected grade as mean, and the given standard deviation. If the sample is higher than 100, re-sample. If the sample is lower than 0 or 5 standard deviations below mean, re-sample Write the list of student...
import math import numpy as np import numpy.linalg from scipy.linalg import solve A = np.array([[-math.cos(math.pi/6),0, math.cos(math.pi/3),0,...
import math import numpy as np import numpy.linalg from scipy.linalg import solve A = np.array([[-math.cos(math.pi/6),0, math.cos(math.pi/3),0, 0, 0], [-math.sin(math.pi/6), 0, -math.sin(math.pi/3), 0, 0, 0], [math.cos(math.pi/6), 1, 0, 1, 0, 0], [math.sin(math.pi/6), 0, 0, 0, 1, 0], [0, -1, -math.cos(math.pi/3), 0, 0, 0], [0, 0, math.sin(math.pi/3), 0, 0, 1]]) b = np.array([0, 2000, 0, 0, 0, 0]) x = [0, 0, 0, 0, 0, 0] def seidel(a, x, b): # Finding length of a(3) n = len(a) # for loop for...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with the random numbers between 1 and 9 (including 0 and 9). - Assume that you are located at (0,0) (upper-left corner) and want to move to (9,9) (lower-right corner) step by step. In each step, you can only move right or down in the array. - Develop a function to simulate random movement from (0,0) to (9,9) and return sum of all cell values...
Using Python : Create a 4×5 4 × 5 array ? X with random value. Print...
Using Python : Create a 4×5 4 × 5 array ? X with random value. Print out ? X , as well as the largest value of each column.
Problem Definition: Problem: Given an array of integers print all pairs of integers a and b...
Problem Definition: Problem: Given an array of integers print all pairs of integers a and b where a + b is equal to a given number. For example, consider the following array and suppose we want to find all pairs of integers a and b where a + b = 16 A= [ 10, 4, 6, 15, 3, 5, 1, 13] The following are pairs that sum to 16: 13, 3 6, 10 15, 1 Your program should print these...
compute and print factorial if it is equal to 6, not equal to 6, and square...
compute and print factorial if it is equal to 6, not equal to 6, and square of the factorial, if the input is equal to 6 ..... C programming
Part A: Compute the derivative of ?(?)=(4?^4 + 2?)(?+9)(?−6) Part B: Compute the derivative of ?(?)=...
Part A: Compute the derivative of ?(?)=(4?^4 + 2?)(?+9)(?−6) Part B: Compute the derivative of ?(?)= (9x^2 + 8x +8)(4x^4 + (6/x^2))/x^3 + 8 Part C: Compute the derivative of ?(?)=(15?+3)(17?+13)/(6?+8)(3?+11).
What does each line of this python code do? import datetime import getpass print("\n\nFinished execution at...
What does each line of this python code do? import datetime import getpass print("\n\nFinished execution at ", datetime.datetime.now()) print(getpass.getuser())
Complete the given C++ program (prob1.cpp) to read an array of integers, print the array, and...
Complete the given C++ program (prob1.cpp) to read an array of integers, print the array, and then find the index of the largest element in the array. You are to write two functions, printArray() and getIndexLargest(), which are called from the main function. printArray() outputs integers to std::cout with a space in between numbers and a newline at the end. getIndexLargest () returns the index of the largest element in the array. Recall that indexes start at 0. If there...
PYTHON Given a 2D array with the layout of the floor of a concert hall and...
PYTHON Given a 2D array with the layout of the floor of a concert hall and the height (in dwillyinches, a logarithmic measurement of height) of each concert attendee, write a program that determines if every attendee can see the front stage. An attendee can see the front stage if they are strickly taller than all of the attendees in front of them. Everyone can see the front-stage in the example below: # FRONT STAGE [[1, 2, 3, 2, 1,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT