fork download
  1. import numpy as np
  2. def f12(x, y):
  3. return float(8*x*x+8*x+6*y-14)
  4. def f21(x, y):
  5. return float(13*x*x-7*y-14)
  6. def maxfunction(x, y):
  7. return float(max(abs(f12(x,y)), abs(f21(x,y))))
  8. x1=float(0.01)
  9. x2=float(-0.01)
  10. delta = round(float(maxfunction(x1, x2)),3)
  11.  
  12. for x in range(-100, 101):
  13. for y in range(-200, 202, 2):
  14. if delta > maxfunction(x / float(100), y / float(100)):
  15. delta = round(float(maxfunction(x / float(100), y / float(100))),3)
  16. x1 =float(x / float(100))
  17. x2 =float(y / float(100))
  18. print("delta = ", delta, " x1 = " , x1, "x2 = ", x2)
Success #stdin #stdout 0.09s 83072KB
stdin
Standard input is empty
stdout
('delta = ', 0.153, ' x1 = ', 0.97, 'x2 = ', -0.24)