无名 发表于 2022-5-8 18:41:27

【HC】高数(Java)


1、代码。package com.zxj.reptile.utils.number; public class Complex {    private double real;//实数    private double image;//虚数   public Complex() {      real = 0;      image = 0;    }   public Complex(double real, double image) {      this.real = real;      this.image = image;    }   //加:(a+bi)+(c+di)=(a+c)+(b+d)i    public Complex add(Complex complex) {      double real = complex.getReal();      double image = complex.getImage();      double newReal = this.real + real;      double newImage = this.image + image;      return new Complex(newReal, newImage);    }   //减:(a+bi)-(c+di)=(a-c)+(b-d)i    public Complex sub(Complex complex) {      double real = complex.getReal();      double image = complex.getImage();      double newReal = this.real - real;      double newImage = this.image - image;      return new Complex(newReal, newImage);    }   //乘:(a+bi)(c+di)=(ac-bd)+(bc+ad)i    public Complex mul(Complex complex) {      double real = complex.getReal();      double image = complex.getImage();      double newReal = this.real * real - this.image * image;      double newImage = this.image * real + this.real * image;      return new Complex(newReal, newImage);    }   //乘:a(c+di)=ac+adi    public Complex mul(double multiplier) {      return mul(new Complex(multiplier, 0));    }   //除:(a+bi)/(c+di)=(ac+bd)/(c^2+d^2) +((bc-ad)/(c^2+d^2))i    public Complex div(Complex complex) {      double real = complex.getReal();      double image = complex.getImage();      double denominator = real * real + image * image;      double newReal = (this.real * real + this.image * image) / denominator;      double newImage = (this.image * real - this.real * image) / denominator;      return new Complex(newReal, newImage);    }   //欧拉公式 e^(ix)=cosx+isinx    public static Complex euler(double x) {      double newReal = Math.cos(x);      double newImage = Math.sin(x)http://cdn.u1.huluxia.com/g3/M02/36/D9/wKgBOV3H0BCAdrPmAAEQAHDV8wo255.jpg
http://cdn.u1.huluxia.com/g3/M02/36/D9/wKgBOV3H0BGAJEPXAAB7c6R6rKQ489.jpg
页: [1]
查看完整版本: 【HC】高数(Java)