Re: Writing natural logarithmic expression in delphi


[ DelphiLand Discussion Forum ] [ Delphi Forum ]

Posted by webmaster Guido on May 12, 2003 at 16:51:30:

In Reply to: Writing natural logarithmic expression in delphi posted by p12297 on May 12, 2003 at 14:45:44:

: I want to write this expression in delphi:
: DF= log(x)/sqrt((sqr(log(y)))+ sqr(pi)); literally natural log of x divided by the square root of (log y squared plus pi squared). Please let me know how to write it.
: Please also tell me if i have to write a function expression for this anywhere in the programme.

: Thanks.
---------------

The natural logarithm is given by Ln(X), not by Log(X). So you were very close :)

You don't have to write a special function, you can calculate the formula directly in your code:

procedure TForm1....;
var
  X, Y, DF: real;
  ...
begin
  ...
  DF := Ln(X) / Sqrt( Sqr(Ln(Y)) + Sqr(pi) );
  ...
end;

Of course you're also allowed to write your own function, say "CalcDF":

function CalcDF(X, Y: real): real;
begin
  Result := Ln(X) / Sqrt( Sqr(Ln(Y)) + Sqr(pi) );
end;

Now, if for example Z has been declared as "real", you can write:
  
DF := CalcDF(X, Y);


Related Articles and Replies:


[ Delphi Forum ]