Answer the question
In order to leave comments, you need to log in
How to raise a number to a negative power without using the Power function?
Calculate the sum of the series with a given degree of accuracy a: Σ(-1)^n*1/(2n+1), with a=0.0001.
Here is the working code. How to raise an integer to a negative power without using power?
uses
SysUtils, math;
var
i,sum,eps:Real;
n:Integer;
begin
sum:=0;
eps:=0.0001;
n:=1;
i:=0;
while eps>i do
begin
i:=1/(2*n+1)*power(-1, n);
sum:=sum+i;
inc(n);
end;
Writeln(sum);
readln;
end.
Answer the question
In order to leave comments, you need to log in
A number to a negative power or a negative number to a power?
A negative number can only be raised to an integer power (it’s not clear from a rational number, but how did we get the concept of “real degree”? - we supplemented the rational by continuity).
Here you need to raise −1 to the power of n, and the easiest way
for this series is to do so. But if we have a series for the sine, which is calculated recurrently, then
x2 := Sqr(x);
...
yNew := -yOld * x2 / ((n - 1) * n);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question