Re: roots



pete <pfiland@xxxxxxxxxxxxxx> writes:
user923005 wrote:
On Jun 24, 9:34 pm, "Bill Cunningham" <nos...@xxxxxxxxxxxxx> wrote:
I have written a program that calculates powers or exponentiation but I
would like to write something that would give any root of any number. I know
this would involve factorials. Anyone have any hints? I don't want to use
the math.h header.

If you include math.h then you can use something like this:

#include <math.h>
double root(double base, double root)
{
return pow(base, 1.0 / root);
}

And you can write a power function without math.h;
but I needed about a year of calculus
before I could understand the Taylor series
that I used when I wrote one.

Fortunately CORDIC's pretty trivial for log and exp, so no need
for Taylor/MacLaurin series, or any in-depth knowledge of calculus.
All you need to know is that exp(a+b)=exp(a)*exp(b) and log(a*b)=
log(a)+log(b).

Phil
--
Marijuana is indeed a dangerous drug.
It causes governments to wage war against their own people.
-- Dave Seaman (sci.math, 19 Mar 2009)
.



Relevant Pages

  • Re: roots
    ... Anyone have any hints? ... To find the xth root of y, find the natural logarithm of y (say, using Taylor series). ... Sorry I couldn't meaningfully involve factorials in this. ...
    (comp.lang.c)
  • Re: roots
    ... but I would like to write something that would give any root of any ... I know this would involve factorials. ... exponent off the bottom). ... A Taylor series will quickly get terrible results as you move away ...
    (comp.lang.c)
  • Re: Forwarding verse Root Hints
    ... I'm not getting the real difference between a fowarder and DNS Root ... Hints as both serve to contact another DNS server if they cannot ... Could you further explain "Root hint servers must have a root zone". ...
    (microsoft.public.win2000.dns)
  • How to KILL Root Hints!!!
    ... and then remove the root ... hints files. ... Public DNS servers. ...
    (microsoft.public.win2000.dns)
  • Forwarding verse Root Hints
    ... Insted of enabling forwarders they deleted all addresses in the Root ... Hints file and entered the DNS servers they want to be queried. ...
    (microsoft.public.win2000.dns)