def lens_makers_formula(n_lens, n_surr, r1, r2):
 if isinstance(n_lens, Medium):
  n_lens = n_lens.refractive_index
 else:
  n_lens = sympify(n_lens)
 if isinstance(n_surr, Medium):
  n_surr = n_surr.refractive_index
 else:
  n_surr = sympify(n_surr)
 r1 = sympify(r1)
 r2 = sympify(r2)
 return (1 / (((n_lens - n_surr) / n_surr) * ((1 / r1) - (1 / r2))))

def lens_makers_formula ( n_lens , n_surr , r1 , r2 ) : if isinstance ( n_lens , Medium ) : n_lens = n_lens . refractive_index else : n_lens = sympify ( n_lens ) if isinstance ( n_surr , Medium ) : n_surr = n_surr . refractive_index else : n_surr = sympify ( n_surr ) r1 = sympify ( r1 ) r2 = sympify ( r2 ) return ( 1 / ( ( ( n_lens - n_surr ) / n_surr ) * ( ( 1 / r1 ) - ( 1 / r2 ) ) ) )
this function calculates focal length of a thin lens .