1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

JavaScriptで複素関数をプロットしてみた

Posted at

See the Pen Plot of Complex Number Function by kob58im (@kob58im) on CodePen.

画面左側がz平面で、画面右側がf(z)平面

複素関数計算部分のソースコード抜粋

//  parameter c is [real part, imaginaly part]
//            it means c[0] is real part,
//                     c[1] is imaginaly part.

function mul(c,d){
  return [c[0]*d[0]-c[1]*d[1],c[0]*d[1]+c[1]*d[0]];
}
// 1/c
function inv(c){
  let t = abs2(c);
  return [c[0]/t,-c[1]/t];
}
// add
function add(c,d){
  return [c[0]+d[0],c[1]+d[1]];
}
function exp(c){
  let r = Math.exp(c[0]);
  return [r*Math.cos(c[1]),r*Math.sin(c[1])]
}
// return real number -pi to pi
function arg(c){
  return Math.atan2(c[1],c[0]);
}
// return real number abs(c)^2
function abs2(c){
  return c[0]*c[0]+c[1]*c[1];
}
function log(c){
  return [Math.log(abs2(c))*0.5,arg(c)];
}
function pow(c,d){
  // c^d = exp(d*log(c))
  return exp(mul(d,log(c)));
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?