python - Math I just cannot translate into code -
i have relatively easy function have no idea how translate code. imported math
module can see need use sqrt
, cos
, , sin
.
below image of function
altfel
translated else
exercise. understand need use bunch of if
/else
statements can't head around it.
just use single if/else
ensure x
, y
in right portion of domain:
in [1]: math import sqrt, cos, sin in [2]: def f(x, y): ...: if (x < -1 or x > 3) , (y < -1 or y > 1): ...: return sqrt(y)/(3 * x - 7) ...: else: ...: return cos(x) + sin(y) ...:
Comments
Post a Comment