computing floating point powers 
Author Message
 computing floating point powers

i need to evaluate the expression e^(-at) where -at is a float value as well.can anybody
please help me with this.



Mon, 24 Apr 2000 03:00:00 GMT  
 computing floating point powers

Quote:

> i need to evaluate the expression e^(-at) where -at is a float value as well.can anybody
> please help me with this.

#include <math.h>

double d;

d  = exp(-a*t);



Mon, 24 Apr 2000 03:00:00 GMT  
 computing floating point powers



Quote:
> i need to evaluate the expression e^(-at) where -at is a float

value as well.can anybody

Quote:
> please help me with this.

Have you looked at the pow() function in math.h?

Jack



Tue, 25 Apr 2000 03:00:00 GMT  
 computing floating point powers


Quote:
(DAVID KOIDL) writes:
> i need to evaluate the expression e^(-at) where -at is a float value
> as well.can anybody please help me with this.

Do you mean e as in Euler's number?  Or just a general float value?
For the latter, use pow(), for the former use exp() -- both are
defined in <math.h>:

#include <math.h>

double   foo = pow(0.35, -1.13);
float    bar = powf(2.0, 0.5);

double   baz = exp(2 * 3.1415926535984);
float    frob = expf(7.0);

Remember that you may have to link your program against additional
math libraries when you compile (depending on the system you're
using).

Cheers,
-M

-- . -.. .. .- . ...- .- .-.. .. ... -  -.-. --- -- .--. --- ... . .-.
Michael J. Fromberger
Software Engineer, Thayer School of Engineering
Dartmouth College, Hanover, New Hampshire, USA

--. ..- .. - .- .-. .. ... -  .-.. .. -. --. ..- .. ... -  -- .--- ..-.

"Alway the nye slye maketh the ferre leeve to be looth."



Tue, 25 Apr 2000 03:00:00 GMT  
 computing floating point powers

Quote:

> #include <math.h>

> double   foo = pow(0.35, -1.13);
> float    bar = powf(2.0, 0.5);

> double   baz = exp(2 * 3.1415926535984);
> float    frob = expf(7.0);

Neither powf() nor expf() are standard C functions.

--
<\___/>      | "Love is a snowmobile racing across the tundra and
/ O O \      | then suddenly it flips over, pinning you underneath.
\_____/ FTB. | At night the ice weasels come..."



Tue, 25 Apr 2000 03:00:00 GMT  
 computing floating point powers

Quote:



> > i need to evaluate the expression e^(-at) where -at is a float
> value as well.can anybody
> > please help me with this.

> Have you looked at the pow() function in math.h?

I doubt very much if the pow() function is in the header
file...

--
<\___/>      | "Love is a snowmobile racing across the tundra and
/ O O \      | then suddenly it flips over, pinning you underneath.
\_____/ FTB. | At night the ice weasels come..."



Tue, 25 Apr 2000 03:00:00 GMT  
 computing floating point powers



Quote:


article

> > > i need to evaluate the expression e^(-at) where -at is a
float
> > value as well.can anybody
> > > please help me with this.

> > Have you looked at the pow() function in math.h?

> I doubt very much if the pow() function is in the header
> file...

Especially since standard headers are not required to be files...


Wed, 26 Apr 2000 03:00:00 GMT  
 computing floating point powers

Jack & Colin engaged in a "pedantic contest"

Quote:
>> > Have you looked at the pow() function in math.h?

>> I doubt very much if the pow() function is in the header
>> file...

>Especially since standard headers are not required to be files...

But if we insert one word,
"Have you looked at the pow() function 'prototyped'  in math.h"
Then the statement is entirely correct and it does not matter if math.h is a
 file or a magic word to the compiler.

Of course, to perform e^x, I  would use exp(), but that is beside the point.
Also, since he was asking for
   e^(-at)
I suspect that what he was REALLY after was:
   double val = exp(-a*t);
Where t is time or some independent variable.

I'm at home, so I say anything I please.



Wed, 26 Apr 2000 03:00:00 GMT  
 computing floating point powers



Quote:
> i need to evaluate the expression e^(-at) where -at is a float value as
well.can anybody
> please help me with this.

Take a look at the exp function.  

(just in case e is a variable, and not the base of natural logarithms, as I
have assumed, take a look at the pow function.)

#include <math.h>



Wed, 26 Apr 2000 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. floating point rounding or floating point printing ?

2. computing powers without the pow() function.

3. Implicit decimal points in floating-point reads

4. Converting floating point to scaled fixed point

5. Converting Microsoft Floating Point type to the IEEE floating

6. float to string to float - decimal points

7. float to string to float - decimal points

8. Need Help: seek an algorithm computing a 3D Volume points giving vertexes

9. Network Computing System floting point problem...

10. Printng Power Point documents using ShellExecute

11. getting wierd error back from Crypto after install of Power Point

12. Some problem with MS Power point using VBA

 

 
Powered by phpBB® Forum Software