HP Forums
Numworks - Question about frac() - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not remotely HP Calculators (/forum-9.html)
+--- Thread: Numworks - Question about frac() (/thread-19610.html)



Numworks - Question about frac() - Pälzer - 03-02-2023 11:45 PM

Hello,
in the office I use the calculators HP48sx, HP19b and another Casio 4000p (fits so nice in the shirt pocket).

HP48sx:
Input: "4.15" [FP] Display: "0.15"
Input: "-3.95" [FP] Display: "-0.95"

now I accidentally made the input with my seldom used Numworks:

Input: "frac(4.15)" Display: "0.15"
Input: "frac(-3.95)" Display: "0.05"

are FP and frac() 2 different commands?
I am confused.

(Please don't hit me right away, I only had 2 years of math (algebra) as an elective in school).

Thank you


RE: Numworks - Question about frac() - rkf - 03-03-2023 08:16 AM

Obviously, the implementations differ for negative arguments. Unfortunately, I'm unfamiliar with C, but who is, may have a look at the source of Numwork's frac here.

I guess Numwork uses floor C function, which gives -4 when applied to -3.95, and if you subtract -4 from -3.95, you are given 0.05?

Also I guess HP is simply truncating what's on the left hand side of the decimal point, so -0.95 is remaining. HP code aficionados know better for sure.

At the end of the day, mathematically speaking 0.05 and -0.95 are the same modulo 1. :-)


RE: Numworks - Question about frac() - Pälzer - 03-03-2023 09:35 AM

addendum:

i have in the meantime entered the examples into WolframAlpha, etc:
always the same result; only Numworks differs

WolframAlpha:
Input: "frac(4.15)" Display: "0.15"
Input: "frac(-3.95)" Display: "-0,95"


RE: Numworks - Question about frac() - C.Ret - 03-03-2023 06:03 PM

Bonjour à toutes et tous,

As a French company based in Paris, Numworks mainly targets the French market and its calculator is particularly suitable for the intended use in our schools.

Therefore, the function \( frac(x) \) corresponds to the definition of the fractional part of the number x and should not be confused with the function giving the decimal part of a number.

Therefore, for any real \(x\), positive or negative, its definition corresponds to \( frac(x)= x - \left \lfloor x\right \rfloor \)

The fractional part of the number \(x\) is therefore always a positive number and is zero only when x is an integer.

For negative real numbers \(x\), \( frac(x) \) will therefore be positive and corresponds to the 1's complement of the decimal part of the number \(x\).


Par exemple:
\( \begin{matrix}frac(-3,85)&=&(-3,85)&-&\left\lfloor-3,85\right\rfloor\\&=&(-3,85)&-&(-4)\\&=&(-3,85)&+&4\\&=&4&-&3,85\\&=&0,15\\\end{matrix} \)



In English, frac(x) can designate the decimal part of a number, which explains why sites corresponding to other standards give a different result.

Hope, this help a bit.
C.Ret


RE: Numworks - Question about frac() - Pälzer - 03-03-2023 11:25 PM

@ C.Ret, your explanation helped me.

Conclusion:
the function frac(x) has a different definition in France than in the (probably!) rest of the world.

Many thanks

(translated with google)


RE: Numworks - Question about frac() - Didier Lachieze - 03-04-2023 07:28 AM

(03-03-2023 11:25 PM)Pälzer Wrote:  Conclusion:
the function frac(x) has a different definition in France than in the (probably!) rest of the world.

Unfortunately it’s another exemple where there is not a universal consensus on the definition of a mathematical notion, and it’s not specific to France.

From Wolfram Mathworld:
Quote: Although Spanier and Oldham (1987) use the same definition as the Wolfram Language, they mention the formula only very briefly and then say it will not be used further. Graham et al. (1994, p. 70), and perhaps most other mathematicians, use the different definition

\( frac(x)= x - \left \lfloor x\right \rfloor \)