标题: [其他] 复变函数表达式计算器zi [打印本页]
作者: slimay 时间: 2021-5-12 17:35 标题: 复变函数表达式计算器zi
本帖最后由 slimay 于 2021-5-12 20:35 编辑
复变函数表达式计算器,支持多重复变函数混合嵌套计算。是实数表达式计算器的升级版, 打通了冥数的计算,所有函数均推广至复域.
第三方进化路线,后者均是前者在多维空间, 多维数域,多维度矩阵 上 的升级.后者在输入降维数据后运行的结果与前者一致.保证了多维度向下兼容性.
REVPOLISH -> ZI //多维表达式计算
FPLOT -> FP3 //多维绘图
I -> MAT //多维综合工具
示例:
> zi sin(5+7i)*cos(6-3i)+sin(5+7i)*i
/***
= -28817/6 + 4899/2(i) //渐进分数表示
= -4802.848508148568 + 2449.503431876684(i) //浮点表示
= 5391.421042267110 * exp[(i)2.669968709666] //极坐标表示
***/
支持实数同名的复变函数:
+, -, *, /, , ^, pi=3.1415926536, e=2.71828182846
rand, round, int, ceil, floor, sqrt, lg, ln, exp, abs, arg
torad, sin, cos, tan, arcsin, arccos, arctan
sinh, cosh, tanh, arcsinh, arccosh, arctanh
存为a.txt, 解码base92格式 : bse -d92 a.txt a.zip- >7Ct'f!!!!'[!.:F?//?_!cs'[!_!2!!%r!!!_4QyyjApeJMHLV;<D\m4<-HI#>,g_Ago)/+%\<Q9*+8X_$-M/LHFZjY>x:vV)iq7kC!3@Gy@9di+*nkz,yi:QM7Sv)9//vN==A0.HM.EN>^)'dbt|lc!:JPxYr@)ycONmF)YK:tu*jpZ<@mL9@8?\QG$0YK)5[$O\_@xdMilvKj{6|S8GxI/Vb;Eh()J{eXX*V*,P<k13GQ%wxS0|{OWXYM#K2%S1m=ZeKy+eMP6Qdy03xyqHUipf]sLj57W:fG$Izl5E&Dc?$GCi^*[5O8@>qHbOv:$.;<+d|U.FV(nR#Xo?&LAYLE,e=J.F928WnJZP3hGDee]-8RIJQ}N8;,<wN]p,!,8h789RGLajgJTN>xt>OluV,^2jHB|u4I&r]41^V8?9Lk=#0-FUhy:ufajKvm#u+&=I>O%*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域- /*
- COMPLEX MATHLIB ©RIGHT@2021~2023 BY SLIMAY
- 复变函数库
- */
-
- #include <math.h>
-
- //定义复数类型
- typedef double Complex;
-
- #define _REZ 0
- #define _IMZ 1
-
- #define MATH_PI 3.1415926535897932
- #define MATH_E 2.7182818284590452
-
- ////////////////////////////////// 定义复恒量
- static const Complex Z_0 [2] = {0, 0};
- static const Complex Z_1 [2] = {1, 0};
- static const Complex Z_i [2] = {0, 1};
- static const Complex Z__i[2] = {0, -1};
- static const Complex Z_pi[2] = {0, MATH_PI};
- static const Complex Z_e [2] = {0, MATH_E };
-
- ////////////////////////////////// 定义复数 模 加、减、乘、除
- //实例化一个复数
- Complex* Z_init(double x, double y)
- {
- Complex* Z_RET = (Complex*) malloc (2 * sizeof(double));
- *(Z_RET + _REZ) = x;
- *(Z_RET + _IMZ) = y;
- return Z_RET;
- }
- //复数的模长, (一维函数)
- Complex* Z_abs(Complex* x)
- {
- double r = sqrt((*(x+_REZ))*(*(x+_REZ))+(*(x+_IMZ))*(*(x+_IMZ)));
- Complex* Z_RET = Z_init(r, 0);
- return Z_RET;
- }
- //角度转弧度, (一维函数,只对实部运算, 虚部归零)
- Complex* Z_torad(Complex* x)
- {
- Complex* Z_RET = Z_init((*(x+_REZ)) / 180.0 * MATH_PI, 0);
- return Z_RET;
- }
- //复数的辐角 (一维函数, 只返回0到2*PI范围内的辐角弧度, 虚部归零)
- Complex* Z_arg(Complex* x)
- {
- double arg = 0;
-
- if((*(x+_REZ)) == 0)
- {
- if((*(x+_IMZ)) != 0)
- {
- arg = ((*(x+_IMZ)) > 0) ?(MATH_PI/2.0) :(-MATH_PI/2.0);
- }
- }
- else
- {
- arg = atan( (*(x+_IMZ)) / (*(x+_REZ)) );
- if((*(x+_REZ)) < 0)
- {
- arg += ((*(x+_IMZ)) > 0) ?(MATH_PI) :(-MATH_PI);
- }
- }
- Complex* Z_RET = Z_init(arg, 0);
- return Z_RET;
- }
- //随机一个复数, 辐角不超过 x的辐角,模长为x的模长.
- Complex* Z_rand(Complex* x)
- {
- double r = sqrt((*(x+_REZ))*(*(x+_REZ))+(*(x+_IMZ))*(*(x+_IMZ)));
- double s = (r < 2) ?(rand() % 8192/8192.0) :(rand() % ((int)r));
- Complex* Z_RET = Z_init(s, 0);
- return Z_RET;
- }
- //复数加
- Complex* Z_add(Complex* x, Complex* y)
- {
- Complex* Z_RET = (Complex*) malloc (2 * sizeof(double));
- *(Z_RET + _REZ) = (*(x+_REZ)) + (*(y+_REZ));
- *(Z_RET + _IMZ) = (*(x+_IMZ)) + (*(y+_IMZ));
- return Z_RET;
- }
- //复数减
- Complex* Z_sub(Complex* x, Complex* y)
- {
- Complex* Z_RET = (Complex*) malloc (2 * sizeof(double));
- *(Z_RET + _REZ) = (*(x+_REZ)) - (*(y+_REZ));
- *(Z_RET + _IMZ) = (*(x+_IMZ)) - (*(y+_IMZ));
- return Z_RET;
- }
- //复数乘
- Complex* Z_mul(Complex* x, Complex* y)
- {
- Complex* Z_RET = (Complex*) malloc (2 * sizeof(double));
- *(Z_RET + _REZ) = (*(x+_REZ))*(*(y+_REZ)) - (*(x+_IMZ))*(*(y+_IMZ));
- *(Z_RET + _IMZ) = (*(x+_REZ))*(*(y+_IMZ)) + (*(x+_IMZ))*(*(y+_REZ));
- return Z_RET;
- }
- //复数除
- Complex* Z_div(Complex* x, Complex* y)
- {
- double r2 = (*(y+_REZ))*(*(y+_REZ)) + (*(y+_IMZ))*(*(y+_IMZ));
- if(r2 == 0)
- {
- printf("Cannot div 0.\n");
- exit(1);
- }
- Complex* Z_RET = (Complex*) malloc (2 * sizeof(double));
- *(Z_RET + _REZ) = ((*(x+_REZ))*(*(y+_REZ)) + (*(x+_IMZ))*(*(y+_IMZ))) / r2;
- *(Z_RET + _IMZ) = ((*(x+_IMZ))*(*(y+_REZ)) - (*(x+_REZ))*(*(y+_IMZ))) / r2;
- return Z_RET;
- }
- //复取余
- Complex* Z_rest(Complex* x, Complex* y)
- {
- if((*(y+_REZ)) == 0)
- {
- printf("Can't % 0.\n");
- exit(1);
- }
- Complex* Z_RET = Z_init((double)(((int)(*(x+_REZ))) % ((int)(*(y+_REZ)))), 0);
- return Z_RET;
- }
-
- ////////////////////////////////// 定义复变函数 (即实变函数在复域上的推广)
- //EXP函数
- Complex* Z_exp(Complex* x)
- {
- Complex* Z_RET = (Complex*) malloc (2 * sizeof(double));
- *(Z_RET + _REZ) = exp(*(x+_REZ)) * cos(*(x+_IMZ));
- *(Z_RET + _IMZ) = exp(*(x+_REZ)) * sin(*(x+_IMZ));
- return Z_RET;
- }
-
- //自然对数 (旧版),0无辐角
- Complex* Z_log2(Complex* x)
- {
- if( (*(x+_REZ)) == 0 )
- {
- printf("Can't ln(0+bi).\n");
- exit(1);
- }
- double r = sqrt((*(x+_REZ))*(*(x+_REZ))+(*(x+_IMZ))*(*(x+_IMZ)));
- Complex* Z_RET = Z_init(log(r), atan((*(x+_IMZ))/(*(x+_REZ))));
- return Z_RET;
- }
- //自然对数
- Complex* Z_ln(Complex* x)
- {
- double r = sqrt((*(x+_REZ))*(*(x+_REZ))+(*(x+_IMZ))*(*(x+_IMZ)));
- if(r ==0)
- {
- printf("Can't ln(0).\n");
- exit(1);
- }
- double arg = (*(Z_arg(x)+_REZ));
- Complex* Z_RET = Z_init(log(r), arg);
- return Z_RET;
- }
-
- //常用对数
- Complex* Z_log10(Complex* x)
- {
- Complex* lnx = Z_ln(x);
- Complex* Z_RET = Z_init((*(lnx+_REZ))/log(10), (*(lnx+_IMZ))/log(10));
- return Z_RET;
- }
-
- //次方函数
- Complex* Z_pow(Complex* x, Complex* y)
- {
- Complex* lnx = Z_ln(x);
- Complex* Z_RET = Z_exp(Z_mul(y, lnx));
- return Z_RET;
- }
-
- //开方函数
- Complex* Z_sqrt(Complex* x)
- {
- Complex* Z_RET = Z_pow(x, Z_init(0.5, 0));
- return Z_RET;
- }
-
- //四舍五入
- Complex* Z_round(Complex* x)
- {
- double r = sqrt((*(x+_REZ))*(*(x+_REZ))+(*(x+_IMZ))*(*(x+_IMZ)));
- Complex* Z_RET = Z_init((*(x+_REZ))/r * (double)((int)r), (*(x+_IMZ))/r * (double)((int)r));
- return Z_RET;
- }
-
- //向下取整
- Complex* Z_floor(Complex* x)
- {
- double r = sqrt((*(x+_REZ))*(*(x+_REZ))+(*(x+_IMZ))*(*(x+_IMZ)));
- Complex* Z_RET = Z_init((*(x+_REZ))/r * (double)(floor(r)), (*(x+_IMZ))/r * (double)((int)r));
- return Z_RET;
- }
-
- //向上取整
- Complex* Z_ceil(Complex* x)
- {
- double r = sqrt((*(x+_REZ))*(*(x+_REZ))+(*(x+_IMZ))*(*(x+_IMZ)));
- Complex* Z_RET = Z_init((*(x+_REZ))/r * (double)(ceil(r)), (*(x+_IMZ))/r * (double)((int)r));
- return Z_RET;
- }
-
- ////////////////////////////////// 定义复变三角函数
- //正弦函数
- Complex* Z_sin(Complex* x)
- {
- Complex* ix = Z_mul( Z_i, x);
- Complex* _ix = Z_mul(Z__i, x);
-
- Complex* Z_RET = Z_mul(Z_init(0, -0.5), Z_sub(Z_exp(ix),Z_exp(_ix)));
- return Z_RET;
- }
- //余弦函数
- Complex* Z_cos(Complex* x)
- {
- Complex* ix = Z_mul( Z_i, x);
- Complex* _ix = Z_mul(Z__i, x);
-
- Complex* Z_RET = Z_mul(Z_init(0.5, 0), Z_add(Z_exp(ix),Z_exp(_ix)));
- return Z_RET;
- }
- //正切函数
- Complex* Z_tan(Complex* x)
- {
- Complex* Z_RET = Z_div(Z_sin(x), Z_cos(x));
- return Z_RET;
- }
-
- //反正弦函数
- Complex* Z_asin(Complex* x)
- {
- Complex* sqrt1subz2 = Z_sqrt(Z_sub(Z_1, Z_mul(x, x)));
- Complex* Z_RET = Z_mul(Z_i, Z_ln(Z_sub(Z_mul(Z_i, x), sqrt1subz2)));
- return Z_RET;
- }
- //反余弦函数
- Complex* Z_acos(Complex* x)
- {
- Complex* sqrt1subz2 = Z_sqrt(Z_sub(Z_1, Z_mul(x, x)));
- Complex* Z_RET = Z_mul(Z__i, Z_ln(Z_sub(x, Z_mul(Z_i, sqrt1subz2))));
- }
- //反正切函数
- Complex* Z_atan(Complex* x)
- {
- Complex* s = Z_init(0,-0.5);
- Complex* Z_RET = Z_mul(s, Z_ln(Z_div(Z_sub(Z_i, x), Z_add(Z_i, x))));
- return Z_RET;
- }
-
- ////////////////////////////////// 定义复变双曲函数
- //双曲正弦函数
- Complex* Z_sinh(Complex* x)
- {
- Complex* _x = Z_init(-(*(x+_REZ)), -(*(x+_IMZ)));
- Complex* Z_RET = Z_mul(Z_init(0.5, 0), Z_sub(Z_exp(x), Z_exp(_x)));
- return Z_RET;
- }
- //双曲余弦函数
- Complex* Z_cosh(Complex* x)
- {
- Complex* _x = Z_init(-(*(x+_REZ)), -(*(x+_IMZ)));
- Complex* Z_RET = Z_mul(Z_init(0.5, 0), Z_add(Z_exp(x), Z_exp(_x)));
- return Z_RET;
- }
- //双曲正切函数
- Complex* Z_tanh(Complex* x)
- {
- Complex* Z_RET = Z_div(Z_sinh(x), Z_cosh(x));
- return Z_RET;
- }
-
- //反双曲正弦函数
- Complex* Z_asinh(Complex* x)
- {
- Complex* sqrtz2add1 = Z_sqrt(Z_add(Z_init(1,0), Z_mul(x, x)));
- Complex* Z_RET = Z_ln(Z_sub(x, sqrtz2add1));
- return Z_RET;
- }
- //反双曲余弦函数
- Complex* Z_acosh(Complex* x)
- {
- Complex* sqrtz2sub1 = Z_sqrt(Z_sub(Z_init(1,0), Z_mul(x, x)));
- Complex* Z_RET = Z_ln(Z_sub(x, sqrtz2sub1));
- return Z_RET;
- }
- //反双曲正切函数
- Complex* Z_atanh(Complex* x)
- {
- Complex* s1 = Z_init(1, 0);
- Complex* halfs1 = Z_init(0.5, 0);
- Complex* Z_RET = Z_mul(halfs1, Z_ln(Z_div(Z_add(s1, x), Z_sub(s1, x))));
- return Z_RET;
- }
复制代码
新第三方预告,升级版的mat加入了矩阵表达式计算器,类似matlab
mat
格式:
mat "[expression1] [expression2] [expression3] [.] ..."
示例:
mat "[A=1,0;1,1] [B=A^(2)] [C=A^(-1)+B] [(A^(-1))-C] [det(A)] [tr(A)] [A^(50)]"
输入格式:
{E = en(2)} <==> [1 0]
[0 1]
{A = 1,,2;3,8,7} <==> [1 0 2]
[3 8 7]
矩阵函数:
+, -, *, ^, A^(-1), A^(n), cp(A), rot(A), en(A)
gs(A), diag(A), lad(A), tri(A)
tr(A), r(A), det(A)
lf(n): 控制精度
example:
mat "[A=1,0;1,1] [B=A^(2)] [C=A^(-1)+B] [(A^(-1))-C] [det(A
You can use the letters A to O to name the matrix
{E = en(2)} <==> [1 0]
[0 1]
{A = 1,,2;3,8,7} <==> [1 0 2]
[3 8 7]
matrix functions:
+, -, *, ^, A^(-1), A^(n), cp(A), rot(A), en(A)
gs(A), diag(A), lad(A), tri(A)
tr(A), r(A), det(A)
lf(n): control print precision
作者: Byaidu 时间: 2021-5-24 00:32
大佬太厉害了
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |