无名商城论坛

搜索
查看: 371|回复: 0

[其他技术] 【HC】高数(Java)

[复制链接]

1万

主题

1万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
32464
发表于 2022-5-8 18:41:27 | 显示全部楼层 |阅读模式

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)

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表