1. math
Does anyone have a list of basic math questions and answers, using big
numbers, like:
12345678901234567890.123456
+9991230000000000.56666666666688889999999
= the answer
x + y = z
x - y = z
x * y = z
x / y = z
with mixed assorted signs, and anything "tricky"? Could you send them to
me to test a string math lib with? Verified answers for your tests would be a
help.
Thanks,
Kat
2. Re: math
Kat wrote:
> Does anyone have a list of basic math questions and answers, using big
> numbers, like:
>
> 12345678901234567890.123456
> +9991230000000000.56666666666688889999999
> = the answer
the answer = 12355670131234567890.69012266666688889999999
> x - y = z
3.1415926535897932384626433832795 - -2.7182818284590452353602874713527
= 5.8598744820488384738229308546322
3.1415926535897932384626433832795 - 2.7182818284590452353602874713527
= 0.4233108251307480031023559119268
-3.1415926535897932384626433832795 - 2.7182818284590452353602874713527
= -5.8598744820488384738229308546322
-3.1415926535897932384626433832795 - -2.7182818284590452353602874713527
= -0.4233108251307480031023559119268
You can also use the double negatives as addition tests.
> x * y = z
3.5121409 * 3.16362908763458525001406154038726382279
= 11.111111111111111111111111111111111111111111111
(The decimal part has 45 ones _but_no_more_)
> x / y = z
The division ones are likely to be the killers if your code has any problems
in it:
355355355355 / 113113122717.85053892523746376986
= 3.1415926535897932384626433832794792408640017539...
(this isn't the exact value of Pi in case you're wondering)
This is a good one:
10 / 81 = 0.12345679012345679012345679012346....
This has powers of two every 4 digits:
10000 / 4999 = 2.000400080016003200640128025605121024204840968193...
By adding zeroes to 10000... and adding nines to 4999... you can
increase the number of digits each power of two fits into.
If you can do factorial by multiplying repeatedly;
1*2*3*....*48*49*50 / 3.1415926535897932384626433832795
= 2617410836119049074025095693555308.086784253501579842420985109612694...
To test your divisors, you can always remultiply by them afterwards and see
how big the error is.
Hope this aimless rambling helped in some way, :)
Carl
PS I used something called 'bc' to get some of the answers here. It's
available on most Unixes like BSD and Linux.
3. Re: math
- Posted by a.tammer at hetnet.nl
Jun 14, 2002
Hi Kat, find adame.e,
it does just what you want
antoine
4. Re: math
On 14 Jun 2002, at 15:47, a.tammer at hetnet.nl wrote:
>
> Hi Kat, find adame.e,
> it does just what you want
It's not in the archives.
Kat
5. Re: math
- Posted by a.tammer at hetnet.nl
Jun 14, 2002
it,s in recent contribs, Kat
a@t
6. Re: math
On 14 Jun 2002, at 17:20, a.tammer at hetnet.nl wrote:
>
> it,s in recent contribs, Kat
I looked there also. Search results returned no matches.
Kat
7. Re: math
- Posted by a.tammer at hetnet.nl
Jun 14, 2002
In that case, Kat, ask Rob where he hid it.
a@t
8. Re: math
Hello Kat,
----------
> ïÔ: Kat <gertie at PELL.NET>
> ëÏÍÕ: EUforum <EUforum at topica.com>
> ôÅÍÁ: Re: math
> äÁÔÁ: 14 ÉÀÎÑ 2002 Ç. 20:38
>
> On 14 Jun 2002, at 17:20, a.tammer at hetnet.nl wrote:
> > it,s in recent contribs, Kat
> I looked there also. Search results returned no matches.
> Kat
Try please:
http://www.RapidEuphoria.com/rups.zip
adam.e is inside that rups.zip, but it seems
to be with an error just in some
of the first lines.
Regards,
Igor Kachan
kinz at peterlink.ru
9. Re: math
- Posted by a.tammer at hetnet.nl
Jun 14, 2002
What error Igor, please tell me
a@t
10. Re: math
Hello Antoine,
----------
> Îò: a.tammer at hetnet.nl
> Êîìó: EUforum <EUforum at topica.com>
> Òåìà: Re: math
> Äàòà: 15 èþíÿ 2002 ã. 0:12
>
> What error Igor, please tell me
>
> a@t
I loaded adam.e into ed.ex and ran it.
Try please the same trick and you'll see
an undeclared AutoRnd variable and get
ex.err file.
Regards,
Igor Kachan
kinz at peterlink.ru
11. Re: math
- Posted by a.tammer at hetnet.nl
Jun 14, 2002
change line 27, AutoRound to AutoRnd, all will be OK
a@t
12. Re: math
Kat,
You have to search on his last name, which as Igor says, yields:
http://www.rapideuphoria.com/rups.zip
which I guess stands for: "Extended Precision Arithmetic" ?
Dan Moyer
----- Original Message -----
From: "Kat" <gertie at PELL.NET>
To: "EUforum" <EUforum at topica.com>
Subject: Re: math
>
> On 14 Jun 2002, at 17:20, a.tammer at hetnet.nl wrote:
>
> >
> > it,s in recent contribs, Kat
>
> I looked there also. Search results returned no matches.
>
> Kat
>
>
>
>
13. Re: math
On 14 Jun 2002, at 14:11, Carl W. wrote:
>
> Kat wrote:
>
> > Does anyone have a list of basic math questions and answers, using big
> > numbers, like:
> >
> > 12345678901234567890.123456
> > +9991230000000000.56666666666688889999999
> > = the answer
>
> the answer = 12355670131234567890.69012266666688889999999
what do you get for
12345678901234567890.123456
* 9991230000000000.56666666666688889999999
?
I got:
1245763286604063362433419567439368917903064237812834436259117110
2092101269882430404839561330867670592640443255599179435915316.92
640443255599179435915316544
Kat
14. Re: math
On 14 Jun 2002, at 14:11, Carl W. wrote:
<snip>
> 3.5121409 * 3.16362908763458525001406154038726382279
> = 11.111111111111111111111111111111111111111111111
> (The decimal part has 45 ones _but_no_more_)
I get
15568664495588241728380923821516765837422221.5686644955882417283
80923821516765837422221111
i am not sure that is correct, but for testing, i used
while 1 do
original = rand(sqrt(1073741823))
puts(1,sprintf("%d",original*original)&"\n")
num_1 = sprintf("%d",original)
num_2 = num_1
puts(1,"num1= "&num_1&"\nnum2= "&num_2&"\n\n")
starttime = time()
junk = seq_multiply(num_1,num_2)
endtime = time()
junk = stripleading(junk)
puts(1,"Time= "&sprintf("%d",endtime-starttime)&"\n"&junk&"\n\npress any
key\n")
writefile = open("D:\\Euphoria\\bignum1\\bignum result.txt","w")
puts(writefile,"num1= "&num_1&"\nnum2=
"&num_2&"\n\n"&sprintf("%d",original*original)&"\n"&junk&"\nTime=
"&sprintf("%d",endtime-starttime))
close(writefile)
if not equal(sprintf("%d",original*original),junk) then abort(0) end if
end while
and i get back the original square every time. Naturally, the largest number i
can test this way is 32767, or i overrange the Eu integer type.
Kat
15. Re: math
Nevermind, i had dropped in an optimisation, and and for testing, i was
passing integers, which it promptly optimised out of the string math code.
Why must i periodically be taught to not code while sleep deprived?
Kat
On 15 Jun 2002, at 13:46, Kat wrote:
>
> On 14 Jun 2002, at 14:11, Carl W. wrote:
>
> <snip>
>
> > 3.5121409 * 3.16362908763458525001406154038726382279
> > = 11.111111111111111111111111111111111111111111111
> > (The decimal part has 45 ones _but_no_more_)
>
> I get
> 15568664495588241728380923821516765837422221.5686644955882417283
> 80923821516765837422221111
>
> i am not sure that is correct, but for testing, i used
>
> while 1 do
> original = rand(sqrt(1073741823))
> puts(1,sprintf("%d",original*original)&"\n")
> num_1 = sprintf("%d",original)
> num_2 = num_1
> puts(1,"num1= "&num_1&"\nnum2= "&num_2&"\n\n")
>
> starttime = time()
> junk = seq_multiply(num_1,num_2)
> endtime = time()
>
> junk = stripleading(junk)
> puts(1,"Time= "&sprintf("%d",endtime-starttime)&"\n"&junk&"\n\npress any
> key\n")
>
>
> writefile = open("D:\\Euphoria\\bignum1\\bignum result.txt","w")
> puts(writefile,"num1= "&num_1&"\nnum2=
> "&num_2&"\n\n"&sprintf("%d",original*original)&"\n"&junk&"\nTime=
> "&sprintf("%d",endtime-starttime))
> close(writefile)
>
> if not equal(sprintf("%d",original*original),junk) then abort(0) end if
>
> end while
>
>
> and i get back the original square every time. Naturally, the largest number i
> can test this way is 32767, or i overrange the Eu integer type.
>
> Kat
>
>
>
>
16. Re: math
Kat wrote:
> Carl wrote:
>
> > Kat wrote:
> >
> > > Does anyone have a list of basic math questions and answers, using big
> > > numbers, like:
> > >
> > > 12345678901234567890.123456
> > > +9991230000000000.56666666666688889999999
> > > = the answer
> >
> > the answer = 12355670131234567890.69012266666688889999999
>
> what do you get for
> 12345678901234567890.123456
> * 9991230000000000.56666666666688889999999
> ?
> I got:
> 1245763286604063362433419567439368917903064237812834436259117110
> 2092101269882430404839561330867670592640443255599179435915316.92
> 640443255599179435915316544
bc gives:
123348517408381858736722887993212092.44431930534843609035949876544
Judging by your later messages, I'm guessing that you've already fixed the
code that gave your answer... :)
Note that when both expressions have a finite number of decimal places, the
number of decimal places in the result (of a multiplication) is always less
than or equal to the sum of the number of decimal places in the two input
values. The same rule applies to the size of the integer part of the result,
so the total number of digits in the whole result follows the same rule too.
Math-heads will notice that this is akin to the fact that log(a) + log(b) =
log(a*b). :)
Carl