code: def betainc(ctx, a, b, x1=0, x2=1, regularized=False):
      if x1 == x2:
          v = 0
      elif not x1:
          if x1 == 0 and x2 == 1:
              v = ctx.beta(a, b)
          else:
              v = x2**a * ctx.hyp2f1(a, 1 - b, a + 1, x2) / a
      else:
          m, d = ctx.nint_distance(a)
          if m <= 0:
              if d < -ctx.prec:
                  h = +ctx.eps
                  ctx.prec *= 2
                  a += h
              elif d < -4:
                  ctx.prec -= d
          s1 = x2**a * ctx.hyp2f1(a, 1 - b, a + 1, x2)
          s2 = x1**a * ctx.hyp2f1(a, 1 - b, a + 1, x1)
          v = (s1 - s2) / a
      if regularized:
          v /= ctx.beta(a, b)
      return v
  
imports: from .functions import defun, defun_wrapped
label_desc: Use image node_id 10 for calling a global function with example usage: betainc(ctx, a, b, x1, x2, regularized) and returns: v