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

1. 使用 Sowya 计算 sin(x)

Posted by haifeng on 2023-12-21 11:00:47 last update 2023-12-21 11:01:43 | Answers (0) | 收藏


$\sin(x)$ 的 Taylor 展开(见问题2722)为

\[
\sin x=x-\frac{1}{3!}x^3+\frac{1}{5!}x^5-\frac{1}{7!}x^7+\cdots+(-1)^{n}\frac{1}{(2n+1)!}x^{2n+1}+\cdots
\]

在 Sowya 中, 首先调整计算精度, 比如精确到小数点后 100 位.

>> setprecision(100)
Now the precision is: 100

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

比如这里计算 $\sin 1$. 使用 sum() 函数.  先计算10项.

>> sum((-1)^n/((2*n+1)!),n,0,10)
0.8414709848078965066525409389542263831247347547521504910395056013623995289262652434908558497261901517
------------------------

不够准确.   调整为计算100项

>> sum((-1)^n/((2*n+1)!),n,0,100)
0.8414709848078965066525023216302989996225630607983710656727517099919104043912396689486397435430526956
------------------------

 

2. 计算 $1*2*3+3*4*5+5*6*7+\cdots+99*100*101$ 的值.

Posted by haifeng on 2023-10-24 18:56:39 last update 2023-10-24 18:58:10 | Answers (0) | 收藏


计算 $1*2*3+3*4*5+5*6*7+\cdots+99*100*101$ 的值.

 

题目来自 C语言练手题(52个小练习)_c语言练习题-CSDN博客

 

解答

使用 Sowya的sum()函数

>> sum((2*k-1)*(2*k)*(2*k+1),k,1,50)
13002450
------------------------

3. 求解下列一元二次方程

Posted by haifeng on 2023-08-30 08:14:03 last update 2023-08-31 08:36:07 | Answers (3) | 收藏


求一元二次方程 

(1)   $112y^2+16y-7.68=0$

 

 

(2)   $112x^2+16x-7=0$

 

 

 

(3)    $x^2-14x-232=0$

 

4. Calculator 的新名字

Posted by haifeng on 2023-02-26 22:30:04 last update 2023-04-05 19:14:04 | Answers (0) | 收藏


Calculator 是计算器的意思, 是十分普通的. 因此应该起个比较特别的名字.

候选: 

Souya,  数学的吴音.  或者 Sowya, 法语发音比较接近吴语中的“数学”发音.

THL ,  maTH Language.  THL 也为了纪念家乡.

 

 

5. 利用递推公式求定积分 $I_n=\int_0^1 \frac{x^n}{x+5}\mathrm{d}x$.

Posted by haifeng on 2023-02-24 22:33:00 last update 2023-02-28 15:21:33 | Answers (1) | 收藏


北太天元实现《数值分析》中的简单递推式 观察舍入误差的爆炸_哔哩哔哩_bilibili

使用 Calculator 求 $I_n=\int_0^1 \frac{x^n}{x+5}\mathrm{d}x$.

首先易得如下递推公式,

\[
I_n=-5*I_{n-1}+\frac{1}{n}
\]

事实上, 

\[
\begin{split}
I_n&=\int_0^1 \frac{x^n}{x+5}\mathrm{d}x=\int_0^1 \frac{x^{n-1}(x+5)-5x^{n-1}}{x+5}\mathrm{d}x\\
&=\int_0^1 x^{n-1}\mathrm{d}x-5\int_0^1 \frac{x^{n-1}}{x+5}\mathrm{d}x\\
&=\frac{1}{n}x^n\biggr|_0^1 -5I_{n-1}\\
&=\frac{1}{n}-5I_{n-1}.
\end{split}
\]

 


于是, 我们可以使用 Calculator 中的函数 printRecursiveSeries 来求由递推公式所确定的序列 $I_n$, 这也是求积分的一个方法.

>> setprecision(20)
in> setprecision(20)
Now the precision is: 20

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

>> printRecursiveSeries(-5*I_k+1/(k+1),I_k,0.0883922160302268689414,20,\n,linenumber)
in> printRecursiveSeries(0-5*I_k+1/(k+1),I_k,0.0883922160302268689414,20,\n,linenumber)
【1】 0.0883922160302268689414
【2】 0.0580389198488656552930
【3】 0.0431387340890050568650
【4】 0.0343063295549747156750
【5】 0.0284683522251264216250
【6】 0.0243249055410345585450
【7】 0.0212326151519700644150
【8】 0.0188369242401496779250
【9】 0.0169264899103627214850
【10】 0.0153675504481863925750
【11】 0.0140713386681589462150
【12】 0.0129766399925386022550
【13】 0.0120398769603839118050
【14】 0.0112291866266518695450
【15】 0.0105207335334073189450
【16】 0.0098963323329634052750
【17】 0.0093418677469476795050
【18】 0.0088462168208171580350
【19】 0.0084004948432826308750
【20】 0.0079975257835868456250

 

----------------
By Calculator

https://zhuanlan.zhihu.com/p/566572045

6. register code

Posted by haifeng on 2023-02-22 19:56:51 last update 2023-02-23 22:04:52 | Answers (0) | 收藏


in> register(code)

This is the register code:

706f02c662ef45331a51abcd2b7dc3cfbe27bccf5bc57d02b751f22820b7d718

>> 

 

atzjg, 2023-2-22

7. [Calculator] 关于递推公式的计算

Posted by haifeng on 2023-02-04 14:18:28 last update 2023-02-04 14:18:28 | Answers (0) | 收藏


Hanoi 问题的递推关系为 $a_n=2a_{n-1}+1$, $a_1=1$.

>> printRecursiveSeries(2*n+1,n,1,10,\n)
in> printRecursiveSeries(2*n+1,n,1,10,\n)
3
7
15
31
63
127
255
511
1023
2047


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


注意输入时 2*n+1 如果忘了乘号 *, 则有

>> printRecursiveSeries(2n+1,n,1,10,\n)
in> printRecursiveSeries(2n+1,n,1,10,\n)
22
223
2224
22225
222226
2222227
22222228
222222229
2222222230
22222222231


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

8. [Calculator]

Posted by haifeng on 2023-02-03 19:10:05 last update 2023-02-04 10:08:41 | Answers (0) | 收藏


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

>> c=3
--------------------
>> a=1
--------------------
>> l=12
--------------------
>> u=21
--------------------
>> t=20
--------------------
>> o=15
--------------------
>> r=18
--------------------
>> c+a+l+c+u+l+a+t+o+r
in> 3+1+12+3+21+12+1+20+15+18

out> 106

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

9. [Bug] Calculator 中关于 % 运算的 Bug

Posted by haifeng on 2022-09-21 11:40:26 last update 2022-09-21 11:40:26 | Answers (1) | 收藏


>> 3 * (2-6 %(3 -7))
in> 3*(2-6%(3-7))

out> 312

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


>> 6%(-4)
in> 6%(-4)

out> -25

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


>> 6%(4)
in> 6%(4)

out> 25

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


>> 6%4
in> 6%4

out> 1

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

 

10. 解不定方程 $7x+4y=1$.

Posted by haifeng on 2022-09-21 00:02:58 last update 2022-09-21 00:02:58 | Answers (0) | 收藏


解不定方程 $7x+4y=1$.

 

>> IndefiniteEquation(7,4)
in> IndefiniteEquation(7,4)
Solve the equation: 7*x+4*y = 1
7==1*4+3
4==1*3+1
1 1
test: 1==4*2-7*1
4*2-7*1 == 1
x = -1+4t
y = 2-7t


-----------***---------

 

>> IndefiniteEquation(7,4;1)
in> IndefiniteEquation(7,4;1)
Solve the indefinite equation :
7*X1+4*X2 = 1

u1=1-3*u0
---------------
X1 = -1*u1+u0
X2 = -1*X1+u1

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

 

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