GMP Library and POWER

C

calimero22

Hi
I'musing the GMP Libraries Mathematics.

I need to calculate 12345678987654321.1234567876554456 ^
9876543212344556676.676767676

How can i do ?
The two variables are type MPF.
Thanks
 
K

Keith Thompson

I'musing the GMP Libraries Mathematics.

I need to calculate 12345678987654321.1234567876554456 ^
9876543212344556676.676767676

How can i do ?
The two variables are type MPF.

Your question isn't about the C language.

I'm sure GMP includes extensive documentation. Did it not answer your
question?
 
C

calimero22

Your question isn't about the C language.

I'm sure GMP includes extensive documentation.  Did it not answer your
question?

--
Keith Thompson (The_Other_Keith) (e-mail address removed)  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"





Ok. scuse me.
The documentation doesn't report then solution.
Thanks adn Scuse me.
 
J

jameskuyper

Hi
I'musing the GMP Libraries Mathematics.

I need to calculate 12345678987654321.1234567876554456 ^
9876543212344556676.676767676

How can i do ?
The two variables are type MPF

The GMP libraries are off-topic in this group, and I know nothing
about them. However, I would like to ask you about the problem you
want to solve. There's strong hints that the numbers you've given are
just examples. However, your example indicates that you want to raise
a fairly large number with LOTS of significant digits to the power of
another very large number which also has LOTS of significant digits.
If the required number of significant digits in the answer must be
comparable, then this is an exceedingly difficult problem. I consider
it extremely unlikely (but admittedly not impossible) that you
actually have a good reason for performing this calculation. Could you
please explain why you want to calculate it? I strongly suspect
someone will be able to point out a way to rearrange your question so
that the information you really need can be found out much more
accurately than the answer to your original question.
 
C

calimero22

The GMP libraries are off-topic in this group, and I know nothing
about them. However, I would like to ask you about the problem you
want to solve. There's strong hints that the numbers you've given are
just examples. However, your example indicates that you want to raise
a fairly large number with LOTS of significant digits to the power of
another very large number which also has LOTS of significant digits.
If the required number of significant digits in the answer must be
comparable, then this is an exceedingly difficult problem. I consider
it extremely unlikely (but admittedly not impossible) that you
actually have a good reason for performing this calculation. Could you
please explain why you want to calculate it? I strongly suspect
someone will be able to point out a way to rearrange your question so
that the information you really need can be found out much more
accurately than the answer to your original question.




Exact
i must find the logarithm and i need to calculate a great float number
power to a great float number.
Is there a discussion group about GMP library ?

Thanks and scuse me again.
Giovanni
 
F

Flash Gordon

<snip reasons why this calculation is at least very difficult and
probably not what is wanted>
Exact
i must find the logarithm

Using a logarithm function woud probably be a better idea!
and i need to calculate a great float number
power to a great float number.

Hmm. I suspect your algorithm needs some work.
Is there a discussion group about GMP library ?

Yes, and there are links to them on the GMP library web site! See
http://gmplib.org/
 
A

Antoninus Twink

i must find the logarithm and i need to calculate a great float number
power to a great float number.

You can't do it out-of-the-box using GMP. For example, there's no way of
calculating e to some floating-point power. You'll need to write your
own exponential and logarithm functions using power series expansions or
whatever your favorite numerical method is.
Is there a discussion group about GMP library ?

This is an excellent place to ask about GMP. You'll annoy the local
grumps, who want to change the character of this group from a C group to
an ISO-C group, but just ignore them - they'll refuse to give you any
useful help anyway.
 
F

Flash Gordon

Antoninus Twink wrote, On 30/09/08 20:11:
On 30 Sep 2008 at 18:01, (e-mail address removed) wrote:


This is an excellent place to ask about GMP.

This is obviously wrong when you consider there are mailing lists with
more posts on GMP per month than this group has per year.
You'll annoy the local
grumps, who want to change the character of this group from a C group to
an ISO-C group, but just ignore them - they'll refuse to give you any
useful help anyway.

Antonious Twink does not care about you getting the best advice
available he just wants to disrupt this group as much as possible by
encouraging off-topic discussions. If he cared about you getting good
advice about how to use GMP he would have pointed you at the mailing
lists dedicated specifically to discussing this library where the real
experts on it (including the developers of it) will see your post and be
able to assist you.

The mailing lists are linked from the GMP web site which can be found by
searching using Google for "GMP GNU" without the quotes.
 
J

jameskuyper

Exact
i must find the logarithm and i need to calculate a great float number
power to a great float number.

It's a lot easier to find the logarithm of that number than it is to
calculate the number itself. In C terms,

long double log_number = logl(12345678987654321.1234567876554456L) *
9876543212344556676.676767676L;

I have no idea how to convert that into GMP terms.

You can even perform that calculation in C and get a fairly large
number of significant digits (though on a typical implementation even
long double won't have as many significant digits as you need.
Is there a discussion group about GMP library ?

Sorry, I don't know.
 
N

Nick Keighley

     As Keith Thompson points out, your question isn't about C but
about the GMP product.

     He might also have pointed out that you don't have enough money
to afford the answer (assuming you mean ^ to signify exponentiation).
The result will have about 1.6E20 decimal digits in the integer part
alone, roughly 5.3E20 bits or 66E18 eight-bit bytes in ordinary
positional notation.  Sixty-six exabytes, or sixty-six thousand
petabytes, or sixty-six million terabytes.  I hope you've got plenty
of RAM, and a machine able to address it all (note that a 64-bit
address is too small).

isn't it worse than that?

log(a ^ b) = log(a) * b

log(a) /= 16
log(a) * b /= 10^20

so log(a ^ b) has 20 decimal places...


(where log is log base 10, ^ is exponentiation
/= is approximatly)

I must have done something wrong here...
 
B

Bartc

Nick said:
isn't it worse than that?

log(a ^ b) = log(a) * b

log(a) /= 16
log(a) * b /= 10^20

so log(a ^ b) has 20 decimal places...


(where log is log base 10, ^ is exponentiation
/= is approximatly)

I must have done something wrong here...

That's what I thought: the answer would be something of the order of 10^N
where N is 10^20.

Outside the typical exponent range of double but not completely out of the
question either (I don't know gmp). I assume an exact result is not called
for (probably not even possible for the example).

Or just knock together an extended-range (if not extended-precision) library
based on this:

struct {double exponent, mantissa;} bignum;
 
C

calimero22

     You wrote "log(a ^ b) has 20 decimal places," and I
wrote "the result will have about 1.6E20 decimal digits,"
so we're in good agreement.  If you've done something wrong
here, then so have I ...

--
Eric Sosman
(e-mail address removed)- Nascondi testo citato

- Mostra testo citato -




Thank you to all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top