from __future__ import division
from sympy import symbols,solve,log
from math import exp
#Variable Declaration:
A,B,r,C = symbols('A B r C');
#Calculation:
res = solve([A + B*log(2)-log(3),A + B*log(4)-log(12)],[A,B])
A = round(float(res[A]),4)
B = round(float(res[B]))
kA = round(exp(A),2)
a = B
#Result:
print 'The equation for rate of reaction is: ',-r,'=',kA*C**a
import scipy.stats as f
#Variable Declaration:
T = [-40,-20,0,10,12,30,40,50,60,80,100,150,200,250,300,400,500]
u = [1.51,1.61,1.71,1.76,1.81,1.86,1.90,1.95,2.00,2.09,2.17,2.38,2.57,2.75,2.93,3.25,3.55]
#Calculations:
B,A,r_value, p_value, std_err = f.linregress(T,u)
#Results:
print 'The value of A in regression model is:',round(A,4)
print 'The value of B in regression model is:',round(B,4)
from __future__ import division
from scipy.optimize import fmin_cobyla as optimize
#Variable Declaration:
def f(x):
return -2.0*x[0] - 1.6*x[1]
def c1(x):
return 16820 - x[0]
def c2(x):
return 1152 - x[1]
def c3(x):
return 1500 - 0.08*x[0] - 0.11*x[1]
def c4(x):
return 6000 - 0.29*x[0] - 0.54*x[1]
def c5(x):
return 11000 - 0.63*x[0] - 0.35*x[1]
def c6(x):
return x[0]
def c7(x):
return x[1]
#Calculation
X = optimize(f,[16820,1152],[c1,c2,c3,c4,c5,c6], disp = 0)
#Result:
print "Maximum Profit is $",round(-f(X)), "/day or $", -365*f(X), "/year"