Questions in category: Bug (Bug)
软件 >> Calculator >> Bug [52]
<[1] [2] [3] [4] [5] [6] >

1. [Bug] 计算 $\sin(\cos(1))$ 的值

Posted by haifeng on 2025-06-08 21:12:02 last update 2025-06-10 10:58:07 | Answers (0) | 收藏


>> :mode clox
> print sin(cos(1));
0.85755321584639341575>

 

但真实的值为

\[\sin(\cos(1))\approx 0.5143952585\]

 

这里计算的结果0.85755321584639341575 实际上是cos(cos(1))的值. 怀疑是 cos(1) 压入栈后 cos 又压入一次.

在 v0.634 中已经修复.

 

不过 Linux 版本出现了错误:

>> :mode clox
> print sin(cos(1));
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 4294967284) > this->size() (which is 1)
Aborted (core dumped)

后来仔细检查了一下, 问题出在 BigNumber.cpp 中的pre_multiplication()函数. 其中有一行

long long pt_pos = multiplication_rs.length() - point_pos;

特别地, 当 multiplication_rs.length() - point_pos 形如 1-13 时, 原本 pt_pos=-12, 但是在32位程序中, 会得到 pt_pos=4294967284, 这在后面的 substr(pt_pos) 语句执行时会出现 out_of_range()的错误. 注意 4294967284+12=4294967296=2^32

问题解决也很简单, 为避免 pt_pos 出现负数, 索性分情况处理. 如下:

LL pt_pos = 0;
int flag = 1;
if (multiplication_rs.length() >= point_pos)
{
pt_pos = multiplication_rs.length() - point_pos;
flag = 1;
}
else
{
pt_pos = point_pos- multiplication_rs.length();
flag = 0;
}
 
 
 

解决日期: 2025-06-10

 

2. [BUG|DATE:20250504]

Posted by haifeng on 2025-05-04 09:51:02 last update 2025-05-05 21:22:18 | Answers (0) | 收藏


>> sqrtn(87178291200,11)
out> 6.1100000010

------------------------

>> 6.1100000010^11
in> 6.1100000010^11

out> 443050584.100352487638815091199115864701330238715760487794319408223063072477872936356617053265500067210000001
------------------------

 


目前暂时解决了问题. 但是运算速度非常慢.

当 n<=10 采用原来的算法, 当 n>10 时, 采用新的算法(但比较慢).

 

>> sqrtn(87178291200,14)
out> 6.04585517138821600067281457369760000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

------------------------

>> sqrtn(87178291200,3)
out> 4434.07243616048241506183956000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

------------------------

 

3. [BUG]20250430

Posted by haifeng on 2025-04-30 08:35:28 last update 2025-05-01 11:17:16 | Answers (0) | 收藏


[BUG] DATE:20250430

 

>> J=[3^n n*3^(n-1);0 3^n]
input> [3^n,n*3^(n-1);0,3^n]
--------------------

3^n     n*3^(n-1)
0       3^n

--------------------
>> A=[1 2;0 2]
input> [1,2;0,2]
--------------------

1       2
0       2

--------------------
>> A*J

out>
3|1*^n  n*3^(n-1)+2|1*3|1*^n
0       2|1*3|1*^n

------------------------

在 v0.631 版本中已经修正.

--------------------
>> A*J

out>
3^n     n*3^(n-1)+2*3^n
0       2*3^n

------------------------

 

4. [Bug]printRecursiveSeries()的迭代计算问题

Posted by haifeng on 2024-12-01 15:42:57 last update 2025-01-17 11:27:52 | Answers (0) | 收藏


>> printRecursiveSeries((4*x_n+(6*x_n^3+6*x_n^2+4*x_n+10)/(5*x_n^4-9*x_n^2-4*x_n-1))/5,x_n,(0.618),3,\n,\linenumber)
0.618
-0.02921664
-:.:99:9978/5-0.02337331
 
 
------------------------
 
>> printRecursiveSeries((4*(x_n)+(6*(x_n)^3+6*(x_n)^2+4*(x_n)+10)/(5*(x_n)^4-9*(x_n)^2-4*(x_n)-1))/5,x_n,0.618,3,\n,\linenumber)
0.618
-0.02921664
-:.:99:9978/5-0.02337331
 
 
------------------------
 

原因在除法有BUG

>> 9.8/(-0.89)
in> 9.8/(-0.89)
 
out> -:.9;123595
------------------------
 

已在 v0.624 版本中修复.


 

>> printRecursiveSeries(a_n,a_n,1,5,\t)
1       1       1       1       1
 
------------------------
 
>> printRecursiveSeries(a_n,a_n+1,1,5,\t)
1       a_n     a_n     a_n     a_n
 
------------------------
 

5. [Sowya] 多项式的运算仍需加强

Posted by haifeng on 2024-12-01 15:17:11 last update 2025-01-20 14:19:32 | Answers (0) | 收藏


>> x-(1|5x+( -6|5x^3-6|5x^2-4|5x+2)/(5x^4-9x^2-4x^1-1))
in> x-(1|5x+(-6|5x^3-6|5x^2-4|5x+2)/(5x^4-9x^2-4x^1-1))
 
out> 4|5x^1
------------------------

这显然是不对的.

 

 

>> x^2/(x^3+x^2)
in> x^2/(x^3+x^2)
 
out>
 quotient> q(x) = 0
remainder> r(x) = x^2
 
0
------------------------
需要加入一元多项式因式分解的功能, 才能使得除法得以化简.
 

 

6. [Bug] 行列式初等变换时不能乘以 1/x

Posted by haifeng on 2024-10-16 13:29:51 last update 2024-10-16 16:00:35 | Answers (0) | 收藏


>> transform(A,r2*(-1))
1       x       2       4
0       2x^2-1x^1       4x^1-2  8x^1-3
0       -3x^1+2 3x^1-6  -13
0       -2x^1+5 -1      x^1-8
 
>> transform(A,c2*(1/x))
        0
0       2x^2-1x^1       4x^1-2  8x^1-3
0       -3x^1+2 3x^1-6  -13
0       -2x^1+5 -1      x^1-8
 
 

 

>> transform(A,c2*(-1))
1       -2      -1x^1   4
0       4x^1-2  2x^2-1x^1       -8x^1+3
0       -3x^1+6 3x^1-2  -13
0       1       2x^1-5  x^1-8
 
>> transform(A,r2-r4*(4x-2))
        -2      -1x^1   4
        4x^1-2  2x^2-1x^1       -8x^1+3
        -3x^1+6 3x^1-2  -13
        1       2x^1-5  x^1-8
 
>> transform(A,r2<-->r3)
1       -2      -1x^1   4
0       1       2x^1-5  x^1-8
0       0       -6x^2+23x^1-10  -4x^2+26x^1-13
0       0       6x^2-24x^1+28   3x^2-30x^1+35
 
>> transform(A,r4+r3)
1       -2      -1x^1   4
0       1       2x^1-5  x^1-8
0       0       -6x^2+23x^1-10  -4x^2+26x^1-13
0       0       (6*x^2-24*x^1+28-6*x^2+23*x^1-10)       (3*x^2-30*x^1+35-4*x^2+26*x^1-13)
 

7. [Bug] 自v0.568开始出现下面的BUG.

Posted by haifeng on 2024-10-13 07:13:15 last update 2024-10-13 08:38:07 | Answers (0) | 收藏


自v0.568开始出现下面的BUG.

 

>> :version
 
Version: 0.568
 
>> a=2
--------------------
>> b=3
--------------------
>> c=6
--------------------
>> (a+b)*c
in> ((a+3)*6
 
out> 6*a+18
------------------------
 
检测 history,  输入 :dev_history. 
 
Version: 0.568
Date: 04/08/2023
Use unordered_map<> to store the variables.
 
 
Date August 04, 2023

是由 Calculator.cpp中的inputcmd2expr()函数引起的. 现已经解决, version 0.615. 

 

 

8. [Bug] transform() 的问题

Posted by haifeng on 2024-10-12 09:39:22 last update 2024-10-12 10:14:18 | Answers (0) | 收藏


>> D1=[4,2,-1,1;6,3,-1,2;12,5,-3,4;16,3,-2,2]
input> [4,2,-1,1;6,3,-1,2;12,5,-3,4;16,3,-2,2]
--------------------
 
4       2       -1      1
6       3       -1      2
12      5       -3      4
16      3       -2      2
 
--------------------
>> D1
in> D1
4       2       -1      1
6       3       -1      2
12      5       -3      4
16      3       -2      2
 
>> transform(D1,c1<-->c3)
-1      2       4       1
-1      3       6       2
-3      5       12      4
-2      3       16      2
 
>> D1
in> D1
-1      2       4       1
-1      3       6       2
-3      5       12      4
-2      3       16      2
 
>> transform(D1,(-1)*c1)
4       2       -1      1
6       3       -1      2
12      5       -3      4
16      3       -2      2
 
>> transform(D1,(-1)*c1)
-1      2       4       1
-1      3       6       2
-3      5       12      4
-2      3       16      2
 
 
还应该加入 transform 的回滚操作 rollback.
 

9. [Bug]sqrt()函数的运算

Posted by haifeng on 2024-09-07 15:30:46 last update 2024-09-07 15:30:46 | Answers (0) | 收藏


>> :mode
Calculating mode: numerical
 
>> sqrt(2)+1/2
in> sqrt(2)+1/2
 
out> 2.5
------------------------
 
 
>> sqrt(2)+3
in> sqrt(2)+3
 
out> 5
------------------------

10. [Bug]2024-8-26

Posted by haifeng on 2024-08-26 17:45:16 last update 2024-08-26 17:53:57 | Answers (0) | 收藏


>> ((x)^4)-(x)^3
in> ((x)^4)-(x)^3
 
out> -1x^3
------------------------
 
>> ((x)^4)-((x)^3)
 
 

>> :mode polyn
Switch into polynomial mode.
 
>> (4x-1)^4
in> (4x-1)^4
 
out> 256x^4-256x^3+96x^2-16x^1+1
------------------------
 
 
>> (4x-1)^3
in> (4x-1)^3
 
out> 64x^3-48x^2+12x^1-1
------------------------
 
 
>> (4x-1)^2
in> (4x-1)^2
 
out> 16x^2-8x^1+1
------------------------
 
 
>> (256x^4-256x^3+96x^2-16x^1+1)-(64x^3-48x^2+12x^1-1)+(16x^2-8x^1+1)+3
in> (256x^4-256x^3+96x^2-16x^1+1)-(64x^3-48x^2+12x^1-1)+(16x^2-8x^1+1)+3
 
out> 256x^4-320x^3+160x^2-36x^1+6|1
------------------------
 
 
>> (4x-1)^4-(4x-1)^3+(4x-1)^2+3
 

 

<[1] [2] [3] [4] [5] [6] >