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

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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -