A company is selling laptop computers. It determines that its total profit, in dollars, is given by

\[P(x) = 0.08x^2 + 80x\] where \(x\) is the number of units produced and sold. Suppose that \(x\) is a function of time, in months, where \(x = 5t + 1\). (a) Find the total profit as a function of time \(t\). (b) Find the rate of change of total profit when \(t = 48\) months.

from sympy import *

x, t = symbols("x, t")

def profit(x):
  return 0.08 * x**2 + 80 * x

def units(t):
  return 5 * t + 1
  
P = simplify(profit(units(Symbol("t"))))
P
## 2.0*t**2 + 400.8*t + 80.08
rate = diff(P, t)
rate
## 4.0*t + 400.8
rate.evalf(subs = {t : 48})
## 592.800000000000

A company determines that its total cost, in thousands of dollars, for producing \(x\) items is

\[C(x) = \sqrt{5x^2 + 60}\] and it plans to boost production \(t\) months from now according to the function \(x(t) = 20t + 40\). How fast will costs be rising 4 months from now?

def cost(x):
  return sqrt(5 * x**2 + 60)
  
def units(t):
  return 20 * t + 40
  
C = simplify(cost(units(Symbol("t"))))
C
## 2*sqrt(500*(t + 2)**2 + 15)
rate = diff(C, t)
rate
## 2*(500*t + 1000)/sqrt(500*(t + 2)**2 + 15)
rate.evalf(subs = {t : 4}) * 1000
## 44702.7372882889