0

When writing a method in java, I noticed that these two functions return the same value.

// Riemann-Siegel theta function using the approximation by the Stirling series
public static double theta (double t) {
return (t/2.0 * StrictMath.log(t/2.0/StrictMath.PI) - t/2.0
    - StrictMath.PI/8.0 + 1.0/48.0/t + 7.0/5760.0/t/t/t);
}

// Riemann-Siegel theta function using the approximation by the Stirling series
public static double theta2 (double t) {
return (t/2.0 * Math.log(t/(2.0*Math.PI)) - t/2.0
    - Math.PI/8.0 + 1.0/(48.0*Math.pow(t, 1)) + 7.0/(5760*Math.pow(t, 3)));
}

What is

7.0/5760.0/t/t/t

doing? Why is this the same as 7.0/(5760*t^3)?

Axion004
  • 943
  • 1
  • 11
  • 37
  • 2
    If I have `8/2/2/2`, that's like `4/2/2`, which is `2/2`, which is 1. If I have `8/2^3`, that's like `8/8`, which is 1 (thought note that `^` is not a Java operator for power-of). This is a math question. – Sotirios Delimanolis Jul 16 '15 at 04:41
  • [Or, rather, `/` is simply the division operator.](http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.17.2) – Sotirios Delimanolis Jul 16 '15 at 04:49

1 Answers1

0

the expression 7.0/5760.0/t1/t2/t3 will be computed from L-R. like-

r=(7.0/5760.0)
r1=(result/t1)
r2=(r1/t2)
r3=(r2/t3)

and r3 is your final result

if you have expression like 8/2*2*2 it will be calculated as same i've explained earlier but in 8/2*(2*2) expression (2*2) will be calculated first because perathesis has higher priority then /. it is also aplly in case of math.pow() function because functions also have the higher priority the operators.

Piyush Mittal
  • 1,860
  • 1
  • 21
  • 39