0

Hey guys I am trying to solve this math problem

Using data in a car magazine, we constructed the mathematical model

y=100e^(-0.0482t)

for the percentage of cars of a certain type still on the road after t years. Using Python, determine the rate of change of the percent of cars still on the road after 5 years.

I came up with this code but I keep getting a syntax error

from sympy import  *
import numpy as np
x= Symbol('X')
y= 100*exp(-0.0482X)
yprime=y.diff(x)
yprimerep=y.diff(5)
print   (yprime)
print   (yprimerep)

Error: line 4 y= 100*exp(-0.0482X) ^ SyntaxError: invalid syntax

Do you know what is wrong here? Either with my math or with my code?

drdrew
  • 61
  • 2
  • 5
  • What is this line supposed to do? `-0.0482X` is no valid number. – Falko Dec 05 '15 at 23:50
  • I was trying to perform 100e^(-0.0482t) so that -0.0482X is from that. I changed the code to be y= 100 * exp(-0.0482 * X) but still got a name error message – drdrew Dec 06 '15 at 00:02

1 Answers1

0

Perhaps try the following:

y= 100 * exp(-0.0482 * x)

J. Murray
  • 1,460
  • 11
  • 19
  • J. Murray - I tried what you suggested and I am now getting the error "NameError: name 'X' is not defined" – drdrew Dec 06 '15 at 00:01
  • Try changing the case of X to x (you have a variable declared as **x**, and Python is a case-sensitive language) – J. Murray Dec 06 '15 at 00:05
  • ok I tried that, now im getting these error Can't calculate 1-th derivative wrt 5. sigh im beginning to think my entire code is incorrect. – drdrew Dec 06 '15 at 00:10