サブ pxt.js   Last modified: Mar 25, 2004
// defined txp
// defined pxg

function pxt(p0, idf)
{
  var ok, xl, xr, xm, p9, u, u2
  ok = 0

  if (p0 == 1.0) {
    return 0.0
  }

  xl = 0.0
  xr = 10.0
  while (xr < 1e30) {
    p9 = txp(xr, idf)
    if (p9 == p0) {
      return xr
    }
    else if (p9 < p0) {
      ok = 1
      break
    }
    xl = xr
    xr *= 10.0
  }

  if (ok == 0) {
    u = pxg(p0/2.0)
    u2 = u*u
    return u + ((u2+1.0)*u)/(4.0*idf)
          + (((5.0*u2+16.0)*u2+3.0)*u)/(96.0*idf*idf)
          + ((((3.0*u2+19)*u2+17.0)*u2-15.0)*u)/(384.0*idf*idf*idf)
  }
  else {
    for (;;) {
      xm = (xl+xr)*0.5
      p9 = txp(xm, idf)
      if (p9 > p0) {
        xl = xm
      }
      else {
        xr = xm
      }
      if (Math.abs(xr-xl)/xm < 1e-10) break
    }
    return xm
  }
}


・ 直前のページへ戻る  ・ E-mail to Shigenobu AOKI

Made with Macintosh