You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to run the following code in the email and it works as I expect for FUCNTION = 0.06xy + 9/y + 22.5/x
The x and y value for critical points are FiniteSet((9.78716910292216, 3.91486764116886), (-4.89358455146108 - 8.47593707426474I, -1.95743382058443 - 3.3903748297059I), (-4.89358455146108 + 8.47593707426474I, -1.95743382058443 + 3.3903748297059I))
Analyzing critical point (9.78716910292216, 3.91486764116886)
The discriminant of our critical value is 0.0108000000000000
The fxx of our critical value is 0.0480000000000000
This is a relative minima
My Value f(a,b) = 6.89678489154198
it produces the values as expected below,
My Value Heigth = 3.91
My Value Front Width = 3.91
My Value Depth = 9.79
Process finished with exit code 0
Howerve, I need some help because when I run this function 0.07xy + 10.0/y + 30.0/x. it errors with this error message below,
Traceback (most recent call last):
File "/Users/admin/PycharmProjects/codeinplace/northwestern_university/400/Week 9/PS9_Q13.py", line 72, in
results = nonlinsolve([partial_x, partial_y], [x, y])
File "/Users/admin/PycharmProjects/codeinplace/venv/lib/python3.7/site-packages/sympy/solvers/solveset.py", line 3675, in nonlinsolve
raise NotImplementedError("Equation not in exact domain. Try converting to rational")
NotImplementedError: Equation not in exact domain. Try converting to rational
Process finished with exit code 1
I appreciate any help
Leo
fromsympyimportsymbols, S, nonlinsolve, lambdify, Abs# Q13fromsympy.solvers.solvesetimport_solve_as_rationaldefD(func, x_sym, y_sym, x_crit, y_crit):
# Calculate the discriminant for a given functionf_x_x=func.diff(x_sym, x_sym)
f_y_y=func.diff(y_sym, y_sym)
f_x_y=func.diff(x_sym, y_sym)
# Create callable functions for each of the derivitives we createdlambd_x_x=lambdify([x_sym, y_sym], f_x_x)
lambd_y_y=lambdify([x_sym, y_sym], f_y_y)
lambd_x_y=lambdify([x_sym, y_sym], f_x_y)
fxx_ab=lambd_x_x(x_crit, y_crit)
fyy_ab=lambd_y_y(x_crit, y_crit)
fxy_ab=lambd_x_y(x_crit, y_crit)
d=fxx_ab*fyy_ab-Abs(fxy_ab) **2print(f"The discriminant of our critical value is {d}")
print(f"The fxx of our critical value is {fxx_ab}")
ifd<0:
print("This is a saddle point")
elifd>0:
iffxx_ab<0:
print("This is relative maxima")
else:
print("This is a relative minima")
# Call our new function and pass in the valuesx, y=symbols('x, y', real=True)
# variables setscf=0.10# cost frontcb=0.07# cost basect=0# cost top (it is 0 because open top)cs1=0.02# cost side1cs2=0.02# cost side2cbk=0.02# cost backvol=250# volumen# bock areas Remember Z = Heigh, Y = Front Width, X = Depthz= (vol/ (x*y))
Bfront=z*yBbase=x*yBTop=x*yBSide1=x*zBSide2=x*zBBack=z*y# print("My Value FUCNTION =",z )f_x_y=cf*Bfront+cb*Bbase+ct*BTop+cs1*BSide1+cs2*BSide2+cbk*BBackf_x_y=22.5*x**(-1)+9*y**(-1)+.06*x*ypartial_x=f_x_y.diff(x)
partial_y=f_x_y.diff(y)
print("My Value FUCNTION1 =", f_x_y)
# Get nonlinear solution and remove imaginary numbersresults=nonlinsolve([partial_x, partial_y], [x, y])
print(f"The x and y value for critical points are {results}")
print(" ")
forresultinlist(results):
ifresult[0].is_realandresult[1].is_real: # Ignore any solutions that are not real numbersprint(f"Analyzing critical point {result}")
print(" ")
# f_x_x = partial_x.diff(x)# print("My Value) f_x_x(a,b) =",f_x_x.subs({x:result[0], y:result[1]}))D(f_x_y, x, y, result[0], result[1])
# declare the symbolsprint("My Value f(a,b) =", f_x_y.subs({x: result[0], y: result[1]}))
print(" ")
print("My Value Heigth =", round(150/ (result[0] *result[1]), 2))
print("My Value Front Width =", round(result[1], 2))
print("My Value Depth =", round(result[0], 2))
/Users/admin/PycharmProjects/codeinplace/venv/bin/python "/Users/admin/PycharmProjects/codeinplace/northwestern_university/400/Week 9/PS9_Q13.py"
My Value FUCNTION1 = 0.06xy + 9/y + 22.5/x
The x and y value for critical points are FiniteSet((9.78716910292216, 3.91486764116886), (-4.89358455146108 - 8.47593707426474I, -1.95743382058443 - 3.3903748297059I), (-4.89358455146108 + 8.47593707426474I, -1.95743382058443 + 3.3903748297059I))
Analyzing critical point (9.78716910292216, 3.91486764116886)
The discriminant of our critical value is 0.0108000000000000
The fxx of our critical value is 0.0480000000000000
This is a relative minima
My Value f(a,b) = 6.89678489154198
My Value Heigth = 3.91
My Value Front Width = 3.91
My Value Depth = 9.79
Process finished with exit code 0
The text was updated successfully, but these errors were encountered:
I'm trying to run the following code in the email and it works as I expect for FUCNTION = 0.06xy + 9/y + 22.5/x
The x and y value for critical points are FiniteSet((9.78716910292216, 3.91486764116886), (-4.89358455146108 - 8.47593707426474I, -1.95743382058443 - 3.3903748297059I), (-4.89358455146108 + 8.47593707426474I, -1.95743382058443 + 3.3903748297059I))
Analyzing critical point (9.78716910292216, 3.91486764116886)
The discriminant of our critical value is 0.0108000000000000
The fxx of our critical value is 0.0480000000000000
This is a relative minima
My Value f(a,b) = 6.89678489154198
it produces the values as expected below,
My Value Heigth = 3.91
My Value Front Width = 3.91
My Value Depth = 9.79
Process finished with exit code 0
Howerve, I need some help because when I run this function 0.07xy + 10.0/y + 30.0/x. it errors with this error message below,
Traceback (most recent call last):
File "/Users/admin/PycharmProjects/codeinplace/northwestern_university/400/Week 9/PS9_Q13.py", line 72, in
results = nonlinsolve([partial_x, partial_y], [x, y])
File "/Users/admin/PycharmProjects/codeinplace/venv/lib/python3.7/site-packages/sympy/solvers/solveset.py", line 3675, in nonlinsolve
raise NotImplementedError("Equation not in exact domain. Try converting to rational")
NotImplementedError: Equation not in exact domain. Try converting to rational
Process finished with exit code 1
I appreciate any help
Leo
/Users/admin/PycharmProjects/codeinplace/venv/bin/python "/Users/admin/PycharmProjects/codeinplace/northwestern_university/400/Week 9/PS9_Q13.py"
My Value FUCNTION1 = 0.06xy + 9/y + 22.5/x
The x and y value for critical points are FiniteSet((9.78716910292216, 3.91486764116886), (-4.89358455146108 - 8.47593707426474I, -1.95743382058443 - 3.3903748297059I), (-4.89358455146108 + 8.47593707426474I, -1.95743382058443 + 3.3903748297059I))
Analyzing critical point (9.78716910292216, 3.91486764116886)
The discriminant of our critical value is 0.0108000000000000
The fxx of our critical value is 0.0480000000000000
This is a relative minima
My Value f(a,b) = 6.89678489154198
My Value Heigth = 3.91
My Value Front Width = 3.91
My Value Depth = 9.79
Process finished with exit code 0
The text was updated successfully, but these errors were encountered: