Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.18 Piecewise functions are sometimes useful when the relationship between a dependent and an independent variable cannot be adequately represented by a single equation. For

2.18 Piecewise functions are sometimes useful when the relationship between a dependent and an independent variable cannot be adequately represented by a single equation. For example, the velocity of a rocket might be described by y(t) 5 e 11t2 2 5t 0 # t # 10 1100 2 5t 10 # t # 20 50t 1 2(t 2 20)2 20 # t # 30 1520e20.2(t230) t . 30 0 otherwise Develop a well-structured function to compute v as a function of t. Then use this function to generate a table of v versus t for t 5 25 to 50 at increments of 0.5.

import math

import numpy as np

def velocity(t):

v=0

if 0 <= t <= 10:

v = 11*t**2 - 5*t

elif 10 <= t <= 20:

v = 1100 - 5*t

elif 20 <= t <= 30:

v = 50*t + 2*((t-20)**2)

elif t >30:

v = 1520*(math.e**(-0.2*(t-30)))

return v

print("+--------+--------+")

print('| %-6s | %-6s |' %('t','v(t)'))

print("+--------+--------+")

for t in np.arange(-5,50.5,0.5):

print('| %-6.1f | %-6.1f |' %(t,velocity(t)))

print("+--------+--------+")

Can anyone please provide analysis for this code.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

7. Where Do We Begin?

Answered: 1 week ago