サブ fxp.js   Last modified: Mar 25, 2004

function fxp(f, df1, df2)
{
  var i1, i2, w, y, p, s, c
  var m2pi = 0.636619772367581343076
  var m_pi = Math.PI
  i1 = 2-(df1%2)
  i2 = 2-(df2%2)
  w = df2/(df2+df1*f)
  y = 1.0-w
  p = Math.sqrt(w)
  s = Math.sqrt(y)
  if (2*i1-i2 == 0) {
    p = 1.0-s
    c = s*w/2.0
  }
  else if (2*i1-i2 == 1) {
    c = s*p/m_pi
    p = 1.0-Math.atan(s/p)*m2pi
  }
  else if (2*i1-i2 == 2) {
    p = w
    c = w*y
  }
  else {
    c = y*p/2.0
  }
  for (; df2 > i2; i2 += 2) {
    p -= 2.0/i2*c
    c *= w*(i1+i2)/i2
  }
  for (; df1 > i1; i1 += 2) {
    p += 2.0/i1*c
    c *= y*(i1+i2)/i1
  }
  return (p < 0.0 && Math.abs(p) < 1e-10) ? 0.0 : p
}


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

Made with Macintosh