# How to use math formula in PL/SQL

• 12-30-2002, 01:50 PM
rkonda99
How to use math formula in PL/SQL
I am planning to write a PL/SQL procedure to perform some math calculations. The math formulas has 'log' function with base 2. [ e.g. log2(25) ]. Would you please provide me your feedback on how to code this in SQL.

The complete formula is something like this.

log2(x1)-log2(x2)-log2(x3)

x1,x2,x3 are the column names in my oracle table and I need to calculate the value for each row in the table using above formula.

Thanks,
Ramesh
• 12-30-2002, 02:00 PM
stecal
log(a,b) returns the log, base a of b

log(2,x1)-log(2,x2)-log(2,x3)
• 12-30-2002, 02:11 PM
stecal
However, what is the relationship among x1, x2, and x3? I'm trying to think of a mathematical situation where you would be subtracting successive logs beyond the case of log x - log y.

log(2/3) = log 2 - log 3

If you have x1/x2, and then divided by x3, or x1 divided by x2/x3, then your equation would make sense. You could do log(2,x1/x2) - log(2,x3), or log(2,x1) - log(2,x2/x3).
• 12-30-2002, 08:30 PM
rkonda99
Thanks
Thanks your feedback stevencallan.
Actually, I have x3/x4, etc.. in place of variables x1,x2,x3 that I stated for simplicity. Your feedback provides answer to my question.
Thanks again.
Ramesh