Monday 10 May 2010

Square Root and Exponential Function in Delphi ( Delphi Tutorial # 8 )

Sqrt() function

In this tutorial we’re going to write some mathematic formulas in Delphi. The first formula is :

To write the above formula in Delphi, we use sqrt() function :

Sqrt((b*b-4*a*c)/(2*a))

Exp() function

There’s no power operator in Pascal Object. But it does not mean that we can not calculate the formula above. Before we calculate the formula, we have to describe it into an exponential function :

So we can write the formula using exp() function and ln() function :

                                                   Exp(b*ln(a))

Example :

program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;

var
x, y : real;
a, b, c : integer;

begin
  // Insert user code here
  a := 2;
  b := 5;
  c := 3;
  x := sqrt((b*b-4*a*c)/(2*a));
  writeln(x:0:1);
  y := exp(b*ln(a));
  writeln(y:0:0);
  readln;
end.

Go to Previous Tutorial or Next Tutorial

8 comments:

  1. hmmm
    thanks yaw,,
    next time dicoba dechh
    tipz na
    :D

    ReplyDelete
  2. bisa dicoba neh, thank's sharingnya kawan
    moga sukses selalu

    ReplyDelete
  3. @ darahbiroe & pakde sulas : you're welcome :)

    ReplyDelete
  4. tutorial delphie y ?!
    wah boleh ne, skalian coba2 . thx y =)

    ReplyDelete
  5. @Norland : thank you
    @berpikir positif : it will be easy when you start learning from the first tutorial in this blog
    @blogger bumi lasinrang : thank you
    @sang pemberontak : So, you have to learn then.. :)

    ReplyDelete

These links are part of a pay per click advertising program called Infolinks. Infolinks is an In Text advertising service; they take my text and create links within it. If you hover your mouse over these double underlined links, you will see a small dialog box containing an advertisement related to the text. You can choose to move the mouse away and go on with your browsing, or to click on the box and visit the relevant ad. Click here to learn more about Infolinks Double Underline Link Ads.