JP4337719B2 - COMPUTER DEVICE AND COMPUTER PROCESSING PROGRAM - Google Patents
COMPUTER DEVICE AND COMPUTER PROCESSING PROGRAM Download PDFInfo
- Publication number
- JP4337719B2 JP4337719B2 JP2004350317A JP2004350317A JP4337719B2 JP 4337719 B2 JP4337719 B2 JP 4337719B2 JP 2004350317 A JP2004350317 A JP 2004350317A JP 2004350317 A JP2004350317 A JP 2004350317A JP 4337719 B2 JP4337719 B2 JP 4337719B2
- Authority
- JP
- Japan
- Prior art keywords
- calculation
- calculation formula
- numerical value
- formula
- detected
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Complex Calculations (AREA)
Description
本発明は、対数関数の計算を高精度に行うための計算装置、および計算処理プログラムに関する。 The present invention relates to a calculation apparatus and a calculation processing program for calculating a logarithmic function with high accuracy.
従来の計算装置において、対数関数の計算は非常に複雑な処理を必要とするために高速化の妨げとなっていたが、これを高速に計算するためのひとつの手法として、IEEE(米国電気電子学会)の浮動小数点精度に一致した数値確度を達成しながら、自然対数を計算するために使用する近似の複雑性を低下させるようにしたものが考えられている(例えば、特許文献1参照。)。 In the conventional computing device, the calculation of the logarithmic function requires a very complicated process, which hinders the speeding-up. As one method for calculating this at a high speed, IEEE (US Electric Electronics) It is conceivable to reduce the complexity of the approximation used to calculate the natural logarithm while achieving numerical accuracy that matches the floating-point accuracy of the academic society (see, for example, Patent Document 1). .
そしてこのような対数関数の計算装置では、計算処理の高速化と共に高精度化が要求されるが、特に、対数関数[log(1+x)]を使用する計算では、xの値が“1”未満(0<|x|<1)と小さい場合に、まずカッコ内の“1+x”の計算において設定有効桁数に応じた桁落ちが発生するため、誤差が大きくなる問題がある。 In such a logarithmic function calculation apparatus, high-speed calculation processing and high precision are required. In particular, in the calculation using the logarithmic function [log (1 + x)], the value of x is “1”. If it is less than “0” (0 <| x | <1), there is a problem that an error increases because a digit loss corresponding to the set effective number of digits occurs in the calculation of “1 + x” in parentheses.
例えば、10進16桁演算において、x=1.23456789E-17で[log(1+x)]を求める場合の代入式は[log(1+1.23456789E-17)]であるが、まずカッコ内の“1+x”の計算の段階での桁落ちによって[log(1)=0]となってしまう。桁落ちが発生しない場合、正しくは[log(1+1.23456789E-17)=1.23456789E-17]となる。 For example, in decimal 16-digit arithmetic, when [log (1 + x)] is obtained with x = 1.23456789E-17, the substitution formula is [log (1 + 1.23456789E-17)]. [Log (1) = 0] due to a digit loss at the calculation stage of “1 + x”. If no digit loss occurs, [log (1 + 1.23456789E-17) = 1.23456789E-17] is correct.
このような誤算を防ぐためC言語では、[log(x)]関数とは別に、関数の変数の部分にそのままxを与えて計算することのできる[log1p(x)(=log(1+x)]関数をプログラム上で定義し、以下のテイラー展開式でxを直接代入した計算を実行することで、xの値が小さくても桁落ちしない計算が行えるようにしている。 In order to prevent such miscalculations, in the C language, [log1p (x) (= log (1 + x) can be calculated by giving x to the variable part of the function as it is, separately from the [log (x)] function. )] The function is defined on the program, and a calculation in which x is directly substituted by the following Taylor expansion formula is executed, so that a calculation without dropping digits can be performed even if the value of x is small.
log(1+x)=x-(1/2)x^2+(1/3)x^3-(1/4)x^4+… (|x|<1)
なお、この明細書中の計算式の記述において[^]の記号の直後の数値は累乗の指数を示し、例えば[x^2]はxの二乗を意味する。
log (1 + x) = x- (1/2) x ^ 2 + (1/3) x ^ 3- (1/4) x ^ 4 +… (| x | <1)
In the description of the calculation formula in this specification, the numerical value immediately after the symbol [^] indicates an exponent of power, for example, [x ^ 2] means the square of x.
一方、前記対数関数の逆関数である指数関数の計算処理についても同様に、特に、指数関数[exp(x)-1]を使用する計算では、xの値が“1”未満(0<|x|<1)と小さい場合に、まず“exp(x)”の計算において計算結果が1の近傍の値となり、その後の“ exp(x)−1”の計算において設定有効桁数に応じた桁落ちが発生するため、誤差が大きくなる問題がある。 On the other hand, in the calculation process of the exponential function that is the inverse function of the logarithmic function, particularly in the calculation using the exponential function [exp (x) -1], the value of x is less than “1” (0 <| When x | <1) is small, the calculation result first becomes a value near 1 in the calculation of “exp (x)”, and the value corresponding to the set effective digit number in the calculation of “exp (x) −1” thereafter. There is a problem that errors are increased because of the loss of digits.
例えば、10進16桁演算において、x=1.23456789E-17で[exp(x)-1]を求める場合の代入式は[exp(1.23456789E-17)-1]であるが、まず“exp(1.23456789E-17)”の計算の段階での桁落ちによって[exp(1.23456789E-17)=1]となってしまう。そして、[exp(1.23456789E-17)-1=0]となり、桁落ちにより計算結果が0になる。桁落ちが発生しない場合、正しくは[exp(1.23456789E-17)-1=1.23456789E-17]となる。 For example, in decimal 16-digit arithmetic, when [exp (x) -1] is obtained with x = 1.23456789E-17, the substitution expression is [exp (1.23456789E-17) -1]. [Exp (1.23456789E-17) = 1] due to a digit loss at the calculation stage of “1.23456789E-17)”. Then, [exp (1.23456789E-17) -1 = 0] is obtained, and the calculation result becomes 0 due to a digit loss. If no digit loss occurs, the correct value is [exp (1.23456789E-17) -1 = 1.23456789E-17].
このため、この指数関数についても[exp(x)]関数とは別に、[exp(x)-1]関数をC言語プログラム上で定義し、以下のテイラー展開式で計算を実行することで、桁落ちしない計算が行えるようにしている。 For this reason, for this exponential function, separately from the [exp (x)] function, the [exp (x) -1] function is defined on the C language program, and the calculation is performed using the following Taylor expansion formula. Calculations without dropping digits are made possible.
exp(x)-1=(1/1!)x+(1/2!)x^2+(1/3!)x^3+(1/4!)x^4+…
このように、対数関数については[log1p(x)]関数を用いることにより精度の高い対数計算が行えるが、数値計算毎にプログラマーが[log1p(x)]関数と[log(x)]関数とを意識して使い分ける必要があり、特に、[log(a+x)]で例えばa=3となったりa=1となったり変化する場合に適切な使い分けを行うことは非常に難しい問題がある。 In this way, with the logarithmic function, the [log1p (x)] function can be used to perform highly accurate logarithmic calculations. However, for each numerical calculation, the programmer can use the [log1p (x)] and [log (x)] functions There is a problem that it is very difficult to use properly when [log (a + x)] changes, for example, a = 3 or a = 1. .
また、指数関数については[exp(x)-1]関数を用いることにより精度の高い指数計算が行えるが、数値計算毎にプログラマーが[exp(x)-1]関数と[exp(x)]関数とを意識して使い分ける必要があり、特に、[exp(x)-a]で例えばa=3となったりa=1となったり変化する場合に適切な使い分けを行うことは非常に難しい問題がある。 As for exponential functions, the [exp (x) -1] function can be used to perform exponential calculations with high accuracy, but the programmer can use [exp (x) -1] and [exp (x)] functions for each numerical calculation. It is necessary to be aware of the function and use it properly, especially when [exp (x) -a] changes, for example, a = 3 or a = 1. There is.
また、計算式中に[10^x]や[x^y]が含まれる場合にも、これらの式は前記指数関数および対数関数に変換されて計算処理されるため、前記同様の問題がある。 In addition, even when [10 ^ x] or [x ^ y] is included in the calculation formula, these formulas are converted into the exponential function and the logarithmic function for calculation processing. .
そして、このような[log(1+x)][exp(x)-1][10^x][x^y]を使用する計算は複利計算、積み立て計算など、様々な分野で頻繁に発生するため大きな問題である。 And such calculations using [log (1 + x)] [exp (x) -1] [10 ^ x] [x ^ y] frequently occur in various fields such as compound interest calculation and accumulation calculation It is a big problem to do.
本発明は、このような問題に鑑みてなされたもので、入力された計算式の状況に応じて対数関数の計算処理を適切に行い、桁落ちのない高精度な計算結果を得ることが可能になる計算装置、および計算処理プログラムを提供することを目的とする。 The present invention has been made in view of such problems, and it is possible to appropriately perform logarithmic function calculation processing according to the state of the input calculation formula, and to obtain a high-precision calculation result without digit loss. An object of the present invention is to provide a calculation device and a calculation processing program.
本発明に係る計算装置は、入力された計算式を記憶する計算式記憶手段と、この計算式記憶手段により記憶された計算式に、1と数値との加減算の計算式部分が含まれているか否かを検知する計算式部分検知手段と、この計算式部分検知手段により前記計算式に、1と数値との加減算の計算式部分が含まれていると検知された場合に、この検知された計算式部分の数値を指数部と仮数部にして記憶すると共に当該計算式部分の検知を示す識別フラグを記憶する検知数値記憶手段と、前記計算式記憶手段により記憶された計算式に前記検知数値記憶手段により記憶された識別フラグが示すところの計算式部分を引数とする対数関数が含まれているか否かを検知する対数関数検知手段と、この対数関数検知手段により前記計算式に前記計算式部分を引数とする対数関数が含まれていると検知された場合に、前記検知数値記憶手段により指数部と仮数部として記憶された数値の絶対値が1未満であるか否かを検知する1未満検知手段と、この1未満検知手段により前記数値の絶対値が1未満であると検知された場合に、前記検知数値記憶手段に記憶された数値を直接用いて高精度に対数関数の計算を行う高精度対数計算手段と、前記1未満検知手段により前記数値の絶対値が1未満でないと検知された場合に、前記計算式部分検知手段により検知された計算式部分の計算結果を用いて対数関数の計算を行う通常対数計算手段と、を備えたことを特徴とする。 The calculation apparatus according to the present invention includes a calculation formula storage means for storing an input calculation formula, and whether the calculation formula stored by the calculation formula storage means includes a calculation formula portion of addition and subtraction of 1 and a numerical value. This is detected when it is detected by the calculation formula part detection means for detecting whether or not the calculation formula part of the addition / subtraction of 1 and a numerical value is included in the calculation formula by the calculation formula part detection means. The numerical value of the calculation formula part is stored as an exponent part and a mantissa part, and the detection numerical value storage means for storing an identification flag indicating the detection of the calculation formula part, and the detection numerical value stored in the calculation formula stored by the calculation formula storage means A logarithmic function detecting means for detecting whether or not a logarithmic function having the calculation formula portion indicated by the identification flag stored by the storage means as an argument is included; and the logarithmic function detecting means adds the calculating formula to the calculating formula. portion When it is detected that a logarithmic function as an argument is included, the detection numerical value storage means detects whether the absolute value of the numerical value stored as the exponent part and the mantissa part is less than 1 or less When the absolute value of the numerical value is detected to be less than 1 by the means and the less than 1 detection means, the logarithmic function is calculated with high accuracy by directly using the numerical value stored in the detected numerical value storage means. When the absolute value of the numerical value is detected to be less than 1 by the accuracy logarithm calculation means and the less than 1 detection means, the logarithmic function is calculated using the calculation result of the calculation formula part detected by the calculation formula part detection means. And normal logarithm calculation means for performing calculation .
これによれば、計算式に含まれる対数関数の引数である1と数値との加減算の計算式部分における「数値」が1未満と小さいか否かを適切に判断して、[log(1+x)]関数を使用した高精度な対数関数の計算と[log(x)]関数を使用した通常の対数関数の計算とが的確に切り換えられることになる。 According to this, it is appropriately determined whether or not the “numerical value” in the calculation formula part of addition and subtraction of 1 and a numerical value argument of the logarithmic function included in the calculation formula is less than 1, and [log (1+ x)] function can be accurately switched between the calculation of the high-precision logarithmic function and the normal logarithmic function using the [log (x)] function.
本発明の請求項1(請求項4)に記載の計算装置(計算処理プログラム)によれば、計算式に含まれる対数関数の引数である1と数値との加減算の計算式部分における「数値」が1未満と小さいか否かを適切に判断して、[log(1+x)]関数を使用した高精度な対数関数の計算と[log(x)]関数を使用した通常の対数関数の計算とを的確に切り換えた計算処理を行うことができる。 According to the computing device of claim 1 (claim 4) of the present invention (calculation processing program), "Numerical" in formulas portion addition and subtraction of 1 and the value, the argument of the logarithmic function included in the formula Of the logarithm function using the [log (1 + x)] function and the normal logarithmic function using the [log (x)] function It is possible to perform a calculation process in which the calculation is accurately switched.
よって本発明によれば、入力された計算式の状況に応じて対数関数の計算処理を適切に行い、桁落ちのない高精度な計算結果を得ることが可能になる計算装置、および計算処理プログラムを提供できる。 Therefore, according to the present invention, a calculation apparatus and a calculation processing program capable of appropriately performing a logarithmic function calculation process according to the state of the input calculation formula and obtaining a high-precision calculation result without any digit loss Can provide.
以下図面により本発明の実施の形態について説明する。 Embodiments of the present invention will be described below with reference to the drawings.
図1は、本発明の実施形態に係わる電子計算装置10の電子回路の構成を示すブロック図である。
FIG. 1 is a block diagram showing a configuration of an electronic circuit of an
この電子計算装置10は、コンピュータ等からなる制御部(CPU)11を備えている。
The
制御部(CPU)11は、直接接続されたPC(パーソナルコンピュータ)端末20Aやインターネットなどの通信ネットワークNを介して接続されたPC端末20Bからの計算依頼信号に応じて、メモリ12内のROM12Aに予め記憶されている計算処理プログラム12a1、あるいは外部記録媒体13から記録媒体読み取り部14を介して読み取られる計算処理プログラム、あるいは通信ネットワーク(インターネット)N上のWebサーバ(この場合はプログラムサーバ(図示せず))から電送制御部15を介してダウンロードされる計算処理プログラムを起動させ、メモリ12内のRAM12Bをワーク(作業用)メモリとして回路各部の動作を制御し計算処理を行なうものである。
The control unit (CPU) 11 stores in the
この制御部(CPU)11には、前記メモリ12、記録媒体読み取り部14、電送制御部15が接続される他、共有メモリ16、USB端子などの外部機器接続部17を介して前記PC端末20Aが直接接続される。
The control unit (CPU) 11 is connected to the
この電子計算装置10では、直接接続PC端末20Aからの通信処理により所望の計算式を伴い入力される計算依頼に応じた計算処理を実行し、その計算結果を当該計算依頼元のPC端末20Aに応答送信したり、ネット接続PC端末20Bからの通信処理により計算処理サーバ21を利用した所望の計算式を伴い入力される計算依頼に応じた計算処理を実行し、その計算結果を当該計算依頼元のPC端末20Bに応答送信したりする。
In this
メモリ12におけるROM12Aには、本電子計算装置10での種々の計算処理を司る前記計算処理プログラム12a1の他に、公式メモリ12a2が備えられる。
The
この公式メモリ12a2には、複利計算式、積み立て計算式など、様々な分野の計算処理において使用される多数の公式が予め記憶されると共に、通常の対数関数計算処理を行うための[log(x)]関数の計算ルーチンと、関数の変数の部分にそのままxを与えて高精度な対数関数計算処理を行うための[log1p(x)(=log(1+x)]関数の計算ルーチンが記憶される。この高精度な対数関数の計算ルーチンでは、以下のテイラー展開式でxを直接代入した計算を実行することで、xの値が小さくても桁落ちしない計算が行える。 The formula memory 12a2 stores in advance a large number of formulas used in various fields of calculation processing such as compound interest calculation formulas, accumulation calculation formulas, and [log (x )] Function calculation routines and [log1p (x) (= log (1 + x)] function calculation routines for performing high-precision logarithmic function calculation processing by directly giving x to the variable part of the function In this high-precision logarithmic function calculation routine, a calculation in which x is directly substituted by the following Taylor expansion formula is executed, so that even if the value of x is small, a calculation without dropping digits can be performed.
log(1+x)=x-(1/2)x^2+(1/3)x^3-(1/4)x^4+… (|x|<1)
さらにまた、公式メモリ12a2には、通常の指数関数計算処理を行うための[exp(x)]関数の計算ルーチンと、高精度な指数関数計算処理を行うための[exp(x)-1]関数の計算ルーチンが記憶される。この高精度な指数関数の計算ルーチンは、以下のテイラー展開式で計算を実行することで、桁落ちしない計算が行える。
log (1 + x) = x- (1/2) x ^ 2 + (1/3) x ^ 3- (1/4) x ^ 4 +… (| x | <1)
Furthermore, in the official memory 12a2, there are [exp (x)] function calculation routines for performing normal exponential function calculation processing and [exp (x) -1] for high-precision exponential function calculation processing. The function calculation routine is stored. This high-precision exponential function calculation routine can perform calculations without dropping digits by executing the following Taylor expansion formula.
exp(x)-1=(1/1!)x+(1/2!)x^2+(1/3!)x^3+(1/4!)x^4+…
メモリ12におけるRAM12Bには、計算式メモリ12b1、計算精度メモリ12b2、変数メモリ12b3、計算式の状況検知レジスタ12b4、計算結果数値メモリ12b5が備えられる。
exp (x) -1 = (1/1!) x + (1/2!) x ^ 2 + (1/3!) x ^ 3 + (1/4!) x ^ 4 +…
The
計算式メモリ12b1には、直接続PC端末20Aやネット接続PC端末20Bからの計算依頼に伴い入力された計算式が格納記憶される。
The calculation formula memory 12b1 stores and stores a calculation formula input in response to a calculation request from the direct
計算精度メモリ12b2には、直接続PC端末20Aやネット接続PC端末20Bからの計算依頼に伴う計算式と共に入力され指定された計算精度(有効桁数)が格納記憶される。
The calculation accuracy memory 12b2 stores and stores the specified calculation accuracy (the number of significant digits) together with a calculation formula associated with a calculation request from the direct
変数メモリ12b3には、前記計算式メモリ12b1に格納された計算式に含まれる変数を示す記号が格納記憶される。 The variable memory 12b3 stores and stores symbols indicating variables included in the calculation formula stored in the calculation formula memory 12b1.
計算式の状況検知レジスタ12b4は、複数のレジスタR1,R2,R3,R4を有し、計算式メモリ12b1に格納される計算式中から「1±数値」の部分または「exp(数値)−1」の部分が検知された場合に、その検知の都度、各レジスタRnに対し、当該「数値」の仮数部、指数部、符号が格納されると共に、「1±数値」の部分が検知された場合にフラグ“1”がセットされる。 The calculation condition detection register 12b4 has a plurality of registers R1, R2, R3, and R4. From the calculation expression stored in the calculation expression memory 12b1, the “1 ± numerical value” portion or “exp (numerical value) −1” ”Is detected, each time the detection is made, the mantissa part, exponent part, and sign of the“ number ”are stored in each register Rn, and the“ 1 ± number ”part is detected. In this case, the flag “1” is set.
計算結果数値メモリ12b5には、前記計算依頼に応じて計算処理された最終の計算結果の数値が記憶される。 The calculation result numerical value memory 12b5 stores the numerical value of the final calculation result calculated according to the calculation request.
すなわち、この電子計算装置10では、所望の計算式を伴う計算依頼に応じた計算処理の過程において、対数関数の[log1p(x)]関数や指数関数の[exp(x)-1]関数によるテイラー展開を使用した高精度な計算処理が必要と仮定される「1±数値」部分や「exp(数値)−1」部分を検知してその内容を状況検知レジスタ12b4で保持し、当該レジスタ12b4で保持された数値が1未満であると判断された場合には前記[log1p(x)]関数(高精度対数関数計算ルーチン)や[exp(x)-1]関数(高精度指数関数計算ルーチン)による高精度な計算処理を行い、1以上であると判断された場合には[log(x)]関数(通常対数関数計算ルーチン)や[exp(x)]関数(通常指数関数計算ルーチン)による通常の対数関数計算処理や通常の指数関数計算処理を行うことで、あらゆる計算において対数関数や指数関数の計算処理が適切に行われるようにする。
That is, in the
次に、前記構成の電子計算装置10による計算機能について説明する。
Next, the calculation function by the
図2は、前記電子計算装置10による計算機能の全体処理を示すフローチャートである。
FIG. 2 is a flowchart showing the overall processing of the calculation function by the
図3は、前記電子計算装置10における計算機能の全体処理に伴う計算式の計算処理を示すフローチャートである。
FIG. 3 is a flowchart showing the calculation processing of the calculation formula accompanying the overall processing of the calculation function in the
図4は、前記電子計算装置10において対数関数を含む計算式[loge(1+1.23456789E-17)]の計算依頼が入力された場合の計算処理に伴うRAM12B上での数値処理状態を示す図である。
FIG. 4 is a diagram showing a numerical processing state on the
図5は、前記電子計算装置10において対数関数を含み変数値を設定した計算式[loge(A):A=1+1.23456789E-17)]の計算依頼が入力された場合の計算処理に伴うRAM12B上での数値処理状態を示す図である。
FIG. 5 shows a calculation process when a calculation request of a calculation formula [loge (A): A = 1 + 1.23456789E-17)] including a logarithmic function and a variable value is input in the
電子計算装置10では、まず計算依頼の種類が「公式計算処理」であるか、「受信した計算式の計算処理」であるかが判断されるもので(ステップS1)、「公式計算処理」の場合は、直接接続PC端末20Aにおいて、ユーザ指定された公式の計算式が通信計算プログラムにて定義された公式メモリから読み出されるか、またはネット接続PC端末20Bにおいて、計算処理サーバ21へアクセスしてユーザ指定された公式の計算式が取得されることで任意の公式計算式が入力され、これと共に所望の計算精度の桁数が入力される(ステップS2)。
The
一方、「受信した計算式の計算処理」の場合は、直接接続PC端末20A、またはネット接続PC端末20Bにおいて、任意の計算式が入力されると共に、計算精度の桁数が入力される(ステップS3)。
On the other hand, in the case of “calculation processing of received calculation formula”, an arbitrary calculation formula is input and the number of digits of calculation accuracy is input in the directly connected
そして、前記直接接続PC端末20Aからの計算依頼が受信された場合には、共有メモリ16に書き込まれた計算式および計算精度のデータが読み出され、また、前記ネット接続PC端末20Bからの計算依頼の場合には、電送制御部15を介してその計算式および計算精度のデータが受信される(ステップS4)。
When a calculation request is received from the directly connected
すると、例えば図4(A)または図5(A)に示すように、前記PC端末20A(20B)から受信された計算式[loge(1+1.23456789E-17)]または変数値を設定した計算式[loge(A):A=1+1.23456789E-17)]および計算精度[16桁]の各データは、図4(B)または図5(B)に示すように、RAM12B内の計算式メモリ12b1および計算精度メモリ12b2に対してそれぞれ格納される(ステップS5)。
Then, for example, as shown in FIG. 4 (A) or FIG. 5 (A), a calculation formula [loge (1 + 1.23456789E-17)] received from the
ここで、前記RAM12B内の計算式メモリ12b1に格納された計算式について、ROM12A内の公式メモリ12にて予め記憶されている何れかの公式の左辺の部分が含まれるか否か判断される(ステップS6)。
Here, it is determined whether or not the formula stored in the calculation formula memory 12b1 in the
例えば計算依頼により受信された計算式について、公式の左辺部分[10^x]や[x^y]が含まれると判断された場合には、当該計算式中の公式の左辺部分[10^x]や[x^y]がそのそれぞれの右辺[exp(x*loge(10))]や[exp(y*loge(x))]に変換され、前記計算式メモリ12b1に書き換えられる(ステップS6→S7)。 For example, if it is determined that the left side part of the formula [10 ^ x] or [x ^ y] is included in the formula received by the calculation request, the left side part of the formula in the formula [10 ^ x ] And [x ^ y] are converted into [exp (x * loge (10))] and [exp (y * loge (x))] respectively on the right side thereof and rewritten in the calculation formula memory 12b1 (step S6). → S7).
そして、前記計算式メモリ12b1に格納された計算式について、図3に示す計算処理が実行される(ステップSA)。 Then, the calculation process shown in FIG. 3 is executed for the calculation formula stored in the calculation formula memory 12b1 (step SA).
一方、前記図4(B)または図5(B)で示したように、計算依頼により受信格納された計算式が[loge(1+1.23456789E-17)]または[loge(A):A=1+1.23456789E-17)]である場合には、公式の左辺部は含まれないと判断され、当該計算式について、図3に示す計算処理が実行される(ステップSA)。 On the other hand, as shown in FIG. 4B or FIG. 5B, the calculation formula received and stored by the calculation request is [loge (1 + 1.23456789E-17)] or [loge (A): A = 1 + 1.23456789E-17)], it is determined that the left side of the formula is not included, and the calculation process shown in FIG. 3 is executed for the calculation formula (step SA).
図3における計算式の計算処理が起動されると、例えば図4(B)または図5(B)で示したように、RAM12B内の計算式メモリ12b1に格納された計算式[loge(1+1.23456789E-17)]または[loge(A):A=1+1.23456789E-17)]が読み出される。このときに、図5(B)で示したように、読み出された計算式中の変数[A]について数値代入の設定[A=1+1.23456789E-17]がある場合には、図5(C)に示すように、当該設定数値を代入した計算式[loge(1+1.23456789E-17)]に書き換えられる(ステップA1)。
When the calculation processing of the calculation formula in FIG. 3 is started, for example, as shown in FIG. 4B or FIG. 5B, the calculation formula [loge (1 ++) stored in the calculation formula memory 12b1 in the
すると、前記読み出された計算式[loge(1+1.23456789E-17)]について、その先頭から順に「1+数値」形式または「1−数値」形式の計算式部分の存在が検知される。この場合に、「数値」とは整数・小数などの各種の数値を指す(ステップA2)。 Then, regarding the read calculation formula [loge (1 + 1.23456789E-17)], the presence of the calculation formula portion in the “1 + numerical value” format or the “1−numerical value” format is detected in order from the top. In this case, the “numerical value” refers to various numerical values such as integers and decimal numbers (step A2).
そして、前記読み出された計算式[loge(1+1.23456789E-17)]について、「1+数値」形式の計算式部分[1+1.23456789E-17]が検知された場合には、図4(C)または図5(D)に示すように、当該計算式[loge(1+1.23456789E-17)]中の「1+数値」形式の計算式部分[1+1.23456789E-17]が状況検知レジスタ12b4の先頭空きレジスタR1の指定に書き換えられて[loge(R1)]とされると共に、このレジスタR1に対して数値部分[+1.23456789E-17]の符号[+]・指数部[-17]・仮数部[1.23456789]が保存され、「1+数値」ありを示すフラグ“1”がセットされる(ステップA3→A4)。 When the calculated formula part [1 + 1.23456789E-17] in the “1 + numerical value” format is detected for the read formula [loge (1 + 1.23456789E-17)], FIG. C) or as shown in FIG. 5D, the calculation formula part [1 + 1.23456789E-17] in the “1 + numerical value” format in the calculation formula [loge (1 + 1.23456789E-17)] is the status detection register. It is rewritten to the specification of the leading free register R1 of 12b4 to be [loge (R1)], and the sign [+] and exponent part [-17] of the numerical part [+ 1.23456789E-17] with respect to this register R1 The mantissa part [1.23456789] is saved, and the flag “1” indicating “1 + numerical value” is set (step A3 → A4).
この後さらに、前記計算式メモリ12b1から読み出された計算式について続きの計算式がある場合には、続く計算式のところからさらに「1+数値」形式または「1−数値」形式の計算式部分の存在が検知され、その存在が検知された場合には、前記同様のレジスタ処理が繰り返される(ステップA5→A6→A3→A4)。 Thereafter, if there is a continuation calculation formula for the calculation formula read out from the calculation formula memory 12b1, the calculation formula portion in the “1 + numerical value” format or the “1-numerical value” format is further added from the subsequent calculation formula. Is detected, and the register processing similar to the above is repeated (steps A5 → A6 → A3 → A4).
そして、前記計算式メモリ12b1から読み出された計算式について、その最後まで前記同様の「1±数値」形式の計算式部分の存在検知処理およびレジスタ処理が繰り返されると、例えば図4(C)または図5(D)に示すように、計算式メモリ12b1に書き換えられて格納されている計算式[loge(R1)]について、前記フラグ“1”がセットされたところの最初の「1±数値」形式の検知部分(この場合は(R1)部分)から順に、対数関数の引数になっているか検知される(ステップA5→A7)。 Then, when the calculation expression read out from the calculation expression memory 12b1 is repeated until the end of the calculation expression portion in the same “1 ± numerical value” format and the register processing are repeated, for example, FIG. Alternatively, as shown in FIG. 5D, for the calculation formula [loge (R1)] rewritten and stored in the calculation formula memory 12b1, the first “1 ± number” when the flag “1” is set. ”Format detection part (in this case, (R1) part), it is detected whether it is an argument of the logarithmic function (step A5 → A7).
ここで、前記計算式[loge(R1)]中の「1±数値」形式の検知部分[(R1)]について、対数関数[loge]の引数になっていると検知された場合には、その指定のレジスタR1に符号[+]・指数部[-17]・仮数部[1.23456789]に書き換えられて格納されている数値の絶対値が1未満であるか否か判断される(ステップA8→A9)。 Here, if it is detected that the detection part [(R1)] in the “1 ± numerical value” format in the calculation formula [loge (R1)] is an argument of the logarithmic function [loge], It is determined whether or not the absolute value of the numerical value rewritten and stored in the designated register R1 with the sign [+], the exponent part [-17], and the mantissa part [1.23456789] is less than 1 (step A8 → A9). ).
そして、対数関数[loge]の引数になっていると検知された「1±数値」形式の検知部分[(R1)]の数値の絶対値[1.23456789E-17]について、1未満であると判断された場合には、当該対数関数の計算がROM12Aに記憶された高精度対数関数計算ルーチンに基づき[log1p(x)]関数を用いたテイラー展開式によって計算精度メモリ12b2に格納された有効桁数に従い高精度に計算実行される(ステップA9→A10)。
Then, the absolute value [1.23456789E-17] of the detected part [(R1)] in the “1 ± numerical value” format detected as being an argument of the logarithmic function [loge] is determined to be less than 1. When the logarithmic function is calculated, the number of significant digits stored in the calculation accuracy memory 12b2 by the Taylor expansion formula using the [log1p (x)] function based on the high-precision logarithmic function calculation routine stored in the
一方、対数関数[loge]の引数になっていると検知された「1±数値」形式の検知部分の数値の絶対値について、1未満ではなく1以上であると判断された場合には、当該対数関数の計算がROM12Aに記憶された通常対数関数計算ルーチンに基づき通常の[log(x)]関数を用いて計算精度メモリ12b2に格納された有効桁数に従い実行される(ステップA9→A11)。
On the other hand, when it is determined that the absolute value of the numerical value of the detected portion in the “1 ± numerical value” format detected as an argument of the logarithmic function [loge] is not less than 1, but 1 or more, The logarithmic function is calculated based on the number of significant digits stored in the calculation accuracy memory 12b2 using the normal [log (x)] function based on the normal logarithmic function calculation routine stored in the
この後さらに、前記計算式メモリ12b1に書き替えられて格納されている計算式について続きの計算式がある場合には、続く計算式のところからさらにレジスタRnに格納されている「1±数値」形式の検知部分が対数関数の引数になっているか検知され、対数関数の引数であると検知された場合には、前記同様の数値絶対値の1未満/1以上判断に従った対数関数の計算実行が繰り返される(ステップA12→A13→A8〜A11)。 Thereafter, when there is a continuation calculation formula rewritten in the calculation formula memory 12b1, there is “1 ± numerical value” stored in the register Rn from the subsequent calculation formula. If it is detected whether the detection part of the format is an argument of the logarithmic function, and if it is detected that it is an argument of the logarithmic function, the calculation of the logarithmic function according to the determination of the absolute value of less than 1/1 or more is the same Execution is repeated (steps A12 → A13 → A8 to A11).
そして、前記計算式メモリ12b1に書き替えられて格納されている計算式について、その最後まで前記同様の「1±数値」形式の検知部分に対する対数関数の引数検知処理および数値絶対値の判断に従った対数関数計算処理が繰り返されると、さらにその計算式について、先頭から順に「exp(数値)−1」形式または「exp(数値)+1」形式の計算式部分の存在が検知される(ステップA12→A14)。 For the calculation formula rewritten and stored in the calculation formula memory 12b1, logarithmic function argument detection processing for the detection portion in the same “1 ± numerical value” format and determination of the absolute value of the numerical value are performed until the end. When the logarithmic function calculation process is repeated, the presence of a calculation formula portion in the form of “exp (numerical value) −1” or “exp (numerical value) +1” is detected in order from the top of the calculation formula (step A12). → A14).
図6は、前記電子計算装置10において指数関数を含み変数値を設定した計算式[exp(A)-1:A=1.23456789E-17)]の計算依頼が入力された場合の計算処理に伴うRAM12B上での数値処理状態を示す図である。
FIG. 6 shows a calculation process when a calculation request of a calculation formula [exp (A) -1: A = 1.23456789E-17)] including an exponential function and a variable value is input in the
例えば図6(A)に示すような、計算依頼に伴い受信された計算式[exp(A)-1:A=1.23456789E-17)]および計算精度[16桁]が、図6(B)に示すように、RAM12B内の計算式メモリ12b1および計算精度メモリ12b2にそれぞれ格納された後(ステップS1〜S5)、図6(C)に示すように、変数[A]に対して設定数値を代入した計算式[exp(1.23456789E-17)-1]に書き換えられた状態で(ステップA1)、前記ステップA2〜A12を通過し、当該計算式[exp(1.23456789E-17)-1]について、「exp(数値)−1」形式の計算式部分が検知された場合には(ステップA14,A15)、図6(D)に示すように、その数値部分[1.23456789E-17]が状況検知レジスタ12b4の先頭空きレジスタR1に対して符号[+]・指数部[-17]・仮数部[1.23456789]として保存されると共に、その数値の絶対値が1未満であるか否か判断される(ステップA16)。
For example, as shown in FIG. 6A, the calculation formula [exp (A) -1: A = 1.23456789E-17)] and the calculation accuracy [16 digits] received with the calculation request are shown in FIG. As shown in FIG. 6, after being stored in the calculation formula memory 12b1 and calculation accuracy memory 12b2 in the
そして、指数関数[exp(数値)−1]であることが検知された数値の絶対値[1.23456789E-17]について、1未満であると判断された場合には、当該指数関数の計算がROM12Aに記憶された高精度指数関数計算ルーチンに基づき[exp(x)-1]関数を用いたテイラー展開式によって計算精度メモリ12b2に格納された有効桁数に従い高精度に計算実行される(ステップA16→A17)。
When it is determined that the absolute value [1.23456789E-17] of the numerical value detected to be the exponential function [exp (numerical value) -1] is less than 1, the calculation of the exponential function is performed in the
一方、指数関数[exp(数値)−1]であることが検知された数値の絶対値について、1未満ではなく1以上であると判断された場合には、当該指数関数の計算がROM12Aに記憶された通常指数関数計算ルーチンに基づき通常の[exp(x)]関数を用いて計算精度メモリ12b2に格納された有効桁数に従い実行される(ステップA16→A18)。
On the other hand, when it is determined that the absolute value of the numerical value detected to be an exponential function [exp (numerical value) -1] is not less than 1, but 1 or more, the calculation of the exponential function is stored in the
この後さらに、前記計算式メモリ12b1に書き替えられて格納されている計算式について続きの計算式がある場合には、続く計算式のところからさらに「exp(数値)−1」形式の計算式部分が検知され、前記同様の数値絶対値の1未満/1以上判断に従った指数関数の計算実行が繰り返される(ステップA19→A20→A15〜A18)。 Thereafter, when there is a continuation calculation formula rewritten and stored in the calculation formula memory 12b1, a calculation formula in the form of “exp (numerical value) −1” is further calculated from the subsequent calculation formula. The portion is detected, and the calculation of the exponential function is repeated according to the determination of the absolute value of the numerical value less than 1/1 or more (steps A19 → A20 → A15 to A18).
そして、前記計算式メモリ12b1に書き替えられて格納されている計算式について、その最後まで前記同様の「exp(数値)−1」形式の検知処理および数値絶対値の判断に従った指数関数計算処理が繰り返されると、残る未計算部分の計算処理が実行され、例えば図4(D)または図5(E)または図6(D)にてそれぞれ示すように、最終的な計算結果の数値データ[1.23456789E-17]がRAM12B内の計算結果数値メモリ12b5に保存される(ステップA19→A21)。
Then, with respect to the calculation formula rewritten and stored in the calculation formula memory 12b1, the exponential function calculation according to the detection processing in the same “exp (numerical value) −1” format and the determination of the absolute value of the numerical value is performed until the end. When the process is repeated, the calculation process of the remaining uncalculated portion is executed, and as shown in FIG. 4D, FIG. 5E, or FIG. [1.23456789E-17] is stored in the calculation result numerical value memory 12b5 in the
こうして、前記図3における一連の計算式の計算処理が実行されると(ステップSA(A1〜A21))、RAM12B内の計算結果数値メモリ12b5に保存された計算結果の数値データが、今回の計算依頼元であるPC端末に対して次のように通知される(ステップS8)。
Thus, when the calculation processing of the series of calculation formulas in FIG. 3 is executed (steps SA (A1 to A21)), the numerical data of the calculation result stored in the calculation result numerical memory 12b5 in the
すなわち、計算依頼元が直接接続PC端末20Aである場合には、計算結果数値メモリ12b5から読み出された計算結果の数値データは共有メモリ16に書き込まれることで、接続部17を介して前記直接接続PC端末20Aへ計算処理の完了が通知される。
That is, when the calculation request source is the directly connected
また、計算依頼元がネット接続PC端末20Bである場合には、計算結果数値メモリ12b5から読み出された計算結果の数値データは、電送制御部15を介して前記ネット接続PC端末20Bへ送信されて計算処理の完了が通知される。
When the calculation request source is the network
図7は、前記電子計算装置10において積立計算の公式を指定し変数値を設定した計算式[FV=PMT*((1+r)^n-1)/r:PMT=100,000,000:r=0.012345678901:n=10)]の計算依頼が入力された場合の計算処理に伴うRAM12B上での数値処理状態(その1)を示す図である。
FIG. 7 shows a calculation formula [FV = PMT * ((1 + r) ^ n-1) /r:PMT=100,000,000:r=0.012345678901] in which the calculation formula is set and the variable value is set in the
図8は、前記電子計算装置10において積立計算の公式を指定し変数値を設定した計算式[FV=PMT*((1+r)^n-1)/r:PMT=100,000,000:r=0.012345678901:n=10)]の計算依頼が入力された場合の計算処理に伴うRAM12B上での数値処理状態(その2)を示す図である。
FIG. 8 shows a calculation formula [FV = PMT * ((1 + r) ^ n-1) /r:PMT=100,000,000:r=0.012345678901] in which the calculation formula is set and the variable value is set in the
例えば図8(A)に示すような、計算依頼に伴い受信された計算式[FV=PMT*((1+r)^n-1)/r:PMT=100,000,000:r=0.012345678901:n=10)]および計算精度[11桁]が、図8(B)に示すように、RAM12B内の計算式メモリ12b1および計算精度メモリ12b2にそれぞれ格納されると(ステップS1〜S5)、図8(C)に示すように、計算式中の公式対応部分[(1+r)^n]が公式メモリ12a2に予め記憶されている該当の公式[x^y=exp(y*loge(x))]に従って[FV=PMT*(exp(n*loge(1+r))-1)/r]に変換され、同計算式メモリ12b1にて書き換えられる(ステップS6→S7)。
For example, as shown in FIG. 8A, the calculation formula [FV = PMT * ((1 + r) ^ n-1) /r:PMT=100,000,000:r=0.012345678901:n=10 )] And the calculation accuracy [11 digits] are stored in the calculation formula memory 12b1 and the calculation accuracy memory 12b2 in the
すると、計算式メモリ12b1から読み出される計算式
[FV=PMT*(exp(n*loge(1+r))-1)/r]
内の変数[PMT][r][n]に対して、それぞれその設定数値である
[PMT=100,000,000:r=0.012345678901:n=10]が代入され、図8(D)に示すように、
[FV=100,000,000*(exp(10*loge(1+0.012345678901))-1)/0.012345678901]
として書き換えられる(ステップA1)。
Then, the calculation formula [FV = PMT * (exp (n * loge (1 + r))-1) / r] read from the calculation formula memory 12b1
[PMT] [r] [n] is substituted with [PMT = 100,000,000: r = 0.012345678901: n = 10], respectively, and as shown in FIG.
[FV = 100,000,000 * (exp (10 * loge (1 + 0.012345678901))-1) /0.012345678901]
(Step A1).
そして、前記数値代入されて書き換えられた計算式
[FV=100,000,000*(exp(10*loge(1+0.012345678901))-1)/0.012345678901]について、「1+数値」形式の計算式部分[1+0.012345678901]が検知された場合には、図8(E)に示すように、当該計算式中の「1+数値」形式の計算式部分[1+0.012345678901]が状況検知レジスタ12b4の先頭空きレジスタR1の指定に書き換えられて
[FV=100,000,000*(exp(10*loge(R1))-1)/0.012345678901]とされると共に、このレジスタR1に対してその数値部分[+0.012345678901]の符号[+]・指数部[-2]・仮数部[1.2345678901]が保存され、「1+数値」ありを示すフラグ“1”がセットされる(ステップA2〜A4)。
For the calculation formula [FV = 100,000,000 * (exp (10 * loge (1 + 0.012345678901))-1) /0.012345678901], the calculation formula portion [1 + 0.012345678901] in the “1 + number” format is used. ] Is detected, the calculation formula portion [1 + 0.012345678901] in the “1 + numerical value” format in the calculation formula is designated as the first free register R1 of the status detection register 12b4 as shown in FIG. To [FV = 100,000,000 * (exp (10 * loge (R1))-1) /0.012345678901] and the sign [+] · exponent of the numerical part [+0.012345678901] for this register R1 The part [-2] and the mantissa part [1.2345678901] are stored, and a flag “1” indicating “1 + numerical value” is set (steps A2 to A4).
ここで、前記計算式[FV=100,000,000*(exp(10*loge(R1))-1)/0.012345678901]中の「1+数値」形式の前記フラグ“1”で示される検知部分[(R1)]について、対数関数[loge]の引数になっていると検知された後、その指定のレジスタR1に符号[+]・指数部[-2]・仮数部[1.2345678901]に書き換えられて格納されている数値の絶対値が1未満であると判断されるので、当該対数関数の計算がROM12Aに記憶された高精度対数関数計算ルーチンに基づき[log1p(x)]関数を用いたテイラー展開式によって計算精度メモリ12b2に格納された有効桁数に従い高精度に計算実行される(ステップA7〜A10)。
Here, the detection part [(R1)] indicated by the flag “1” in the form of “1 + numerical value” in the formula [FV = 100,000,000 * (exp (10 * loge (R1))-1) /0.012345678901] Is detected as an argument of the logarithmic function [loge], and is then rewritten and stored in the designated register R1 as a sign [+], an exponent part [-2], and a mantissa part [1.2345678901]. Since it is determined that the absolute value of the numerical value is less than 1, the calculation accuracy of the logarithmic function is calculated by the Taylor expansion formula using the [log1p (x)] function based on the high-precision logarithmic function calculation routine stored in the
具体的には、[loge(1+0.012345678901)=1.2270092482E-02]として計算され、図8(F)に示すように、計算式メモリ12b1内の計算式は、
[FV=100,000,000*(exp(10*(1.2270092482E-02)-1)/0.012345678901]となる。
Specifically, it is calculated as [loge (1 + 0.012345678901) = 1.2270092482E-02]. As shown in FIG. 8F, the calculation formula in the calculation formula memory 12b1 is
[FV = 100,000,000 * (exp (10 * (1.2270092482E-02) -1) /0.012345678901].
すると、当該計算式について、「exp(数値)−1」形式の計算式部分[exp(10*(1.2270092482E-02)-1]が検知され、図8(G)に示すように、その数値部分[10*(1.2270092482E-02)=1.2270092482E-01]が状況検知レジスタ12b4の先頭空きレジスタR2に対して符号[+]・指数部[-1]・仮数部[1.2270092482]として保存される(ステップA14,A15)。 Then, a calculation formula portion [exp (10 * (1.2270092482E-02) -1] in the form of “exp (numerical value) −1” is detected for the calculation formula, and as shown in FIG. The part [10 * (1.2270092482E-02) = 1.2270092482E-01] is stored as the sign [+], the exponent part [-1], and the mantissa part [1.2270092482] with respect to the first free register R2 of the status detection register 12b4. (Steps A14 and A15).
そして、前記指数関数[exp(数値)−1]であることが検知された数値の絶対値[1.2270092482E-01]について、1未満であると判断されるので、当該指数関数の計算がROM12Aに記憶された高精度指数関数計算ルーチンに基づき[exp(x)-1]関数を用いたテイラー展開式によって計算精度メモリ12b2に格納された有効桁数に従い高精度に計算実行される(ステップA16→A17)。
Then, since the absolute value [1.2270092482E-01] of the numerical value detected to be the exponential function [exp (numerical value) -1] is determined to be less than 1, the calculation of the exponential function is stored in the
具体的には、[exp(1.2270092482E-01)=0.13054625206]として計算され、図8(G)に示すように、計算式メモリ12b1内の計算式は、
[FV=100,000,000*(0.13054625206)/0.012345678901]となる。
Specifically, it is calculated as [exp (1.2270092482E-01) = 0.13054625206]. As shown in FIG. 8G, the calculation formula in the calculation formula memory 12b1 is
[FV = 100,000,000 * (0.13054625206) /0.012345678901].
そして、残る未計算部分の計算処理が実行され、図8(H)に示すように、最終的な計算結果の数値データ[1,057,424,651.2]がRAM12B内の計算結果数値メモリ12b5に保存される(ステップA21)。
Then, the calculation processing of the remaining uncalculated portion is executed, and as shown in FIG. 8H, the final calculation result numerical data [1,057,424,651.2] is stored in the calculation result numerical memory 12b5 in the
すると、前記RAM12B内の計算結果数値メモリ12b5に保存された計算結果の数値データ[1,057,424,651.2]が、今回の計算依頼元であるPC端末20A(20B)に対して通知される(ステップS8)。
Then, the numerical data [1,057,424,651.2] of the calculation result stored in the calculation result numerical memory 12b5 in the
したがって、前記構成の電子計算装置10による計算機能によれば、所望の計算式を伴う計算依頼に応じた計算処理の過程において、対数関数の[log1p(x)]関数や指数関数の[exp(x)-1]関数によるテイラー展開を使用した高精度な計算処理が必要と仮定される「1±数値」部分や「exp(数値)−1」部分を検知してその内容を状況検知レジスタ12b4で保持し、当該レジスタ12b4で保持された数値が1未満であると判断された場合には前記[log1p(x)]関数(高精度対数関数計算ルーチン)や[exp(x)-1]関数(高精度指数関数計算ルーチン)による高精度な計算処理を行い、1以上であると判断された場合には[log(x)]関数(通常対数関数計算ルーチン)や[exp(x)]関数(通常指数関数計算ルーチン)による通常の対数関数計算処理や通常の指数関数計算処理を行うことで、あらゆる計算において対数関数や指数関数の計算処理が適切に行われるようにしたので、予めプログラマーが数値計算毎に意識して[log1p(x)]関数と[log(x)]関数や[exp(x)-1]関数と[exp(x)]関数を使い分けておく必要なく、容易に桁落ちのない高精度な計算結果を得ることができる。
Therefore, according to the calculation function of the
なお、前記実施形態では、対数関数の計算について、全般に渡り自然対数[loge(x)]の場合を対象にして説明したが、常用対数[log10(x)]の場合であっても、自然対数[loge(x)]の計算数値と常用対数[log10(x)]の計算数値とは、
log10(x)=(loge(x))/2.30258509
と一定の比率で異なるだけなので、対数関数の計算結果に当該定率の差を加味するだけで何れの底の対数関数についても前記同様の計算処理により容易に桁落ちのない高精度な計算結果を得ることができる。
In the above-described embodiment, the calculation of the logarithmic function has been described in the case of the natural logarithm [loge (x)] over the whole, but even in the case of the common logarithm [log 10 (x)], What is the calculated value of the natural logarithm [loge (x)] and the calculated value of the common logarithm [log 10 (x)]?
log 10 (x) = (loge (x)) / 2.30258509
Therefore, by simply adding the difference of the constant rate to the logarithmic function calculation result, the logarithmic function of any base can easily obtain a high-precision calculation result with no precision loss by the same calculation process. Obtainable.
なお、前記実施形態において記載した手法、すなわち、図2のフローチャートに示す計算機能の全体処理、図3のフローチャートに示す前記計算機能の全体処理に伴う計算式の計算処理等の各手法は、コンピュータに実行させることができるプログラムとして、メモリカード(ROMカード、RAMカード等)、磁気ディスク(フロッピー(登録商標)ディスク、ハードディスク等)、光ディスク(CD−ROM、DVD等)、半導体メモリ等の外部記録媒体13に格納して配布することができる。そして、コンピュータは、この外部記録媒体13に記録されたプログラムを記録媒体読み取り部14によって読み込み、この読み込んだプログラムによって動作が制御されることにより、前記実施形態において説明した対数関数や指数関数の計算を伴う計算式の計算機能を実現し、前述した手法による同様の処理を実行することができる。
Note that the methods described in the embodiment, that is, the calculation function overall processing shown in the flowchart of FIG. 2 and the calculation formula calculation processing accompanying the overall processing of the calculation function shown in the flowchart of FIG. As a program that can be executed, external recording such as a memory card (ROM card, RAM card, etc.), magnetic disk (floppy (registered trademark) disk, hard disk, etc.), optical disk (CD-ROM, DVD, etc.), semiconductor memory, etc. It can be stored in the medium 13 and distributed. Then, the computer reads the program recorded in the external recording medium 13 by the recording
また、前記各手法を実現するためのプログラムのデータは、プログラムコードの形態として通信ネットワーク(インターネット)N上を伝送させることができ、この通信ネットワーク(インターネット)Nに接続されたコンピュータ端末(プログラムサーバ)から前記のプログラムデータを取り込み、前述した対数関数や指数関数の計算を伴う計算式の計算機能を実現することもできる。 Further, program data for realizing each of the above methods can be transmitted on a communication network (Internet) N as a program code form, and a computer terminal (program server) connected to the communication network (Internet) N ) From the program data, and the calculation function of the calculation formula involving the logarithmic function and the exponential function can be realized.
なお、本願発明は、前記実施形態に限定されるものではなく、実施段階ではその要旨を逸脱しない範囲で種々に変形することが可能である。さらに、前記実施形態には種々の段階の発明が含まれており、開示される複数の構成要件における適宜な組み合わせにより種々の発明が抽出され得る。例えば、実施形態に示される全構成要件から幾つかの構成要件が削除されたり、幾つかの構成要件が組み合わされても、発明が解決しようとする課題の欄で述べた課題が解決でき、発明の効果の欄で述べられている効果が得られる場合には、この構成要件が削除されたり組み合わされた構成が発明として抽出され得るものである。 Note that the present invention is not limited to the above-described embodiment, and various modifications can be made without departing from the scope of the invention in the implementation stage. Further, the embodiments include inventions at various stages, and various inventions can be extracted by appropriately combining a plurality of disclosed constituent elements. For example, even if some constituent requirements are deleted from all the constituent requirements shown in the embodiment or some constituent features are combined, the problem described in the column of the problem to be solved by the invention can be solved. When the effect described in the column of effect is obtained, a configuration in which this constituent requirement is deleted or combined can be extracted as an invention.
10 …電子計算装置
11 …CPU(制御部)
12 …メモリ
12A…ROM
12a1…計算処理プログラム
12a2…公式メモリ
12B…RAM
12b1…計算式メモリ
12b2…計算精度メモリ
12b3…変数メモリ
12b4…計算式の状況検知レジスタ
12b5…計算結果数値メモリ
13 …外部記録媒体
14 …記録媒体読取部
15 …電送制御部
16 …共有メモリ
17 …外部機器接続部
20A…直接接続PC端末
20B…ネット接続PC端末
21 …計算処理サーバ
N …通信ネットワーク(インターネット)
10: Electronic computing device 11: CPU (control unit)
12 ...
12a1 ... calculation processing program 12a2 ...
12b1 ... Calculation formula memory 12b2 ... Calculation accuracy memory 12b3 ... Variable memory 12b4 ... Calculation formula status detection register 12b5 ... Calculation result numerical memory 13 ...
Claims (4)
入力された計算式を記憶する計算式記憶手段と、
この計算式記憶手段により記憶された計算式に、1と数値との加減算の計算式部分が含まれているか否かを検知する計算式部分検知手段と、
この計算式部分検知手段により前記計算式に、1と数値との加減算の計算式部分が含まれていると検知された場合に、この検知された計算式部分の数値を指数部と仮数部にして記憶すると共に当該計算式部分の検知を示す識別フラグを記憶する検知数値記憶手段と、
前記計算式記憶手段により記憶された計算式に前記検知数値記憶手段により記憶された識別フラグが示すところの計算式部分を引数とする対数関数が含まれているか否かを検知する対数関数検知手段と、
この対数関数検知手段により前記計算式に前記計算式部分を引数とする対数関数が含まれていると検知された場合に、前記検知数値記憶手段により指数部と仮数部として記憶された数値の絶対値が1未満であるか否かを検知する1未満検知手段と、
この1未満検知手段により前記数値の絶対値が1未満であると検知された場合に、前記検知数値記憶手段に記憶された数値を直接用いて高精度に対数関数の計算を行う高精度対数計算手段と、
前記1未満検知手段により前記数値の絶対値が1未満でないと検知された場合に、前記計算式部分検知手段により検知された計算式部分の計算結果を用いて対数関数の計算を行う通常対数計算手段と、
を備えたことを特徴とする計算装置。 A calculation device for calculating a formula including a function,
Calculation formula storage means for storing the input calculation formula;
A calculation formula part detection means for detecting whether or not the calculation formula stored in the calculation formula storage means includes a calculation formula part of addition and subtraction of 1 and a numerical value;
When this calculation formula part detection means detects that the calculation formula includes a calculation formula part of addition and subtraction of 1 and a numerical value, the numerical value of the detected calculation formula part is converted into an exponent part and a mantissa part. And a detection numerical value storage means for storing an identification flag indicating detection of the calculation formula part ,
Logarithmic function detection means for detecting whether or not the calculation formula stored by the calculation formula storage means includes a logarithmic function whose argument is the calculation formula portion indicated by the identification flag stored by the detected numerical value storage means When,
When the logarithmic function detection means detects that the calculation formula includes a logarithmic function having the calculation formula part as an argument, the absolute value of the numerical value stored as the exponent part and the mantissa part by the detected numerical value storage means Less than 1 detection means for detecting whether the value is less than 1;
High-precision logarithmic calculation for calculating a logarithmic function with high accuracy by directly using a numerical value stored in the detected numerical value storage means when the absolute value of the numerical value is detected to be less than 1 by the less than 1 detection means Means,
Ordinary logarithmic calculation for calculating a logarithmic function using the calculation result of the formula part detected by the formula part detection means when the absolute value of the numerical value is detected to be less than 1 by the less than 1 detection means Means,
A computing device comprising:
前記高精度対数計算手段および前記通常対数計算手段は、前記桁数記憶手段により記憶された有効桁数に従って対数関数の計算を行うことを特徴とする請求項1に記載の計算装置。 Furthermore, it comprises digit number storage means for storing the number of significant digits of the input calculated numerical value,
2. The calculation apparatus according to claim 1, wherein the high-precision logarithm calculation unit and the normal logarithm calculation unit calculate a logarithmic function according to the number of significant digits stored in the digit number storage unit.
前記コンピュータを、
入力された計算式を記憶する計算式記憶手段、
この計算式記憶手段により記憶された計算式に、1と数値との加減算の計算式部分が含まれているか否かを検知する計算式部分検知手段、
この計算式部分検知手段により前記計算式に、1と数値との加減算の計算式部分が含まれていると検知された場合に、この検知された計算式部分の数値を指数部と仮数部にして記憶すると共に当該計算式部分の検知を示す識別フラグを記憶する検知数値記憶手段、
前記計算式記憶手段により記憶された計算式に前記検知数値記憶手段により記憶された識別フラグが示すところの計算式部分を引数とする対数関数が含まれているか否かを検知する対数関数検知手段、
この対数関数検知手段により前記計算式に前記計算式部分を引数とする対数関数が含まれていると検知された場合に、前記検知数値記憶手段により指数部と仮数部として記憶された数値の絶対値が1未満であるか否かを検知する1未満検知手段、
この1未満検知手段により前記数値の絶対値が1未満であると検知された場合に、前記検知数値記憶手段に記憶された数値を直接用いて高精度に対数関数の計算を行う高精度対数計算手段、
前記1未満検知手段により前記数値の絶対値が1未満でないと検知された場合に、前記計算式部分検知手段により検知された計算式部分の計算結果を用いて対数関数の計算を行う通常対数計算手段、
として機能させるようにしたコンピュータ読み込み可能な計算処理プログラム。 A calculation processing program for controlling a computer of a calculation device,
The computer,
Calculation formula storage means for storing the input calculation formula,
Calculation formula part detection means for detecting whether or not the calculation formula stored in the calculation formula storage means includes a calculation formula part of addition and subtraction of 1 and a numerical value;
When this calculation formula part detection means detects that the calculation formula includes a calculation formula part of addition and subtraction of 1 and a numerical value, the numerical value of the detected calculation formula part is converted into an exponent part and a mantissa part. Detection numerical value storage means for storing an identification flag indicating detection of the calculation formula part
Logarithmic function detection means for detecting whether or not the calculation formula stored by the calculation formula storage means includes a logarithmic function whose argument is the calculation formula portion indicated by the identification flag stored by the detected numerical value storage means ,
When the logarithmic function detection means detects that the calculation formula includes a logarithmic function having the calculation formula part as an argument, the absolute value of the numerical value stored as the exponent part and the mantissa part by the detected numerical value storage means Less than 1 detection means for detecting whether the value is less than 1;
High-precision logarithmic calculation for calculating a logarithmic function with high accuracy by directly using a numerical value stored in the detected numerical value storage means when the absolute value of the numerical value is detected to be less than 1 by the less than 1 detection means means,
Ordinary logarithmic calculation for calculating a logarithmic function using the calculation result of the formula part detected by the formula part detection means when the absolute value of the numerical value is detected to be less than 1 by the less than 1 detection means means,
A computer-readable calculation processing program designed to function as a computer.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2004350317A JP4337719B2 (en) | 2004-12-02 | 2004-12-02 | COMPUTER DEVICE AND COMPUTER PROCESSING PROGRAM |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2004350317A JP4337719B2 (en) | 2004-12-02 | 2004-12-02 | COMPUTER DEVICE AND COMPUTER PROCESSING PROGRAM |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2006163529A JP2006163529A (en) | 2006-06-22 |
JP4337719B2 true JP4337719B2 (en) | 2009-09-30 |
Family
ID=36665512
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2004350317A Active JP4337719B2 (en) | 2004-12-02 | 2004-12-02 | COMPUTER DEVICE AND COMPUTER PROCESSING PROGRAM |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP4337719B2 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10970045B2 (en) | 2018-12-17 | 2021-04-06 | Samsung Electronics Co., Ltd. | Apparatus and method for high-precision compute of log1p( ) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP4812022B2 (en) * | 2006-12-19 | 2011-11-09 | 株式会社国際電気通信基礎技術研究所 | Arithmetic processing device and program |
-
2004
- 2004-12-02 JP JP2004350317A patent/JP4337719B2/en active Active
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10970045B2 (en) | 2018-12-17 | 2021-04-06 | Samsung Electronics Co., Ltd. | Apparatus and method for high-precision compute of log1p( ) |
Also Published As
Publication number | Publication date |
---|---|
JP2006163529A (en) | 2006-06-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20160062954A1 (en) | Flexible high-speed generation and formatting of application-specified strings | |
EP2430522B1 (en) | Decimal floating-point quantum exception detection | |
US20100299651A1 (en) | Robust testing for discrete-time and continuous-time system models | |
US20160092163A1 (en) | Machine instructions for converting from decimal floating point format to packed decimal format | |
US20160092164A1 (en) | Machine instructions for converting to decimal floating point format from packed decimal format | |
JP2009271598A (en) | Processor | |
Erle et al. | Potential speedup using decimal floating-point hardware | |
JP4337719B2 (en) | COMPUTER DEVICE AND COMPUTER PROCESSING PROGRAM | |
US7752250B2 (en) | Rounding floating point division results | |
CN113342671A (en) | Method, device, electronic equipment and medium for verifying operation module | |
US8495114B1 (en) | System and methods for determining attributes for arithmetic operations with fixed-point numbers | |
US7941473B2 (en) | Calculation apparatus and storage medium in which calculation program is stored | |
JP2011186999A (en) | Device for supporting conversion of floating point representation program to fixed point representation and support program thereof | |
CA1173164A (en) | Fraction calculator | |
JP6335329B2 (en) | Program dependent part visualization device, method, and program | |
Wang | Processor support for decimal floating-point arithmetic | |
Jorgensen et al. | Exact floating point | |
JPH01282633A (en) | Non-normalized number processing system | |
Shepherd | Using mathematical logic and formal methods to write correct microcode | |
US8510360B2 (en) | Calculating large precision common logarithms | |
Gander et al. | How a Computer Calculates | |
Armstrong | Java & monetary data | |
JPS59142652A (en) | Managing system of elapsed time | |
JP2005031847A (en) | Method, program, and device for integer arithmetic operation | |
JP2005316685A (en) | Program management device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20070306 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20090128 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20090203 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20090327 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20090609 |
|
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20090622 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 4337719 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120710 Year of fee payment: 3 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120710 Year of fee payment: 3 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130710 Year of fee payment: 4 |