static public InterestRate impliedRate(final double c,final double time,final DayCounter resultDC,final Compounding comp,final Frequency freq){
  final double t=time;
  final double f=freq.toInteger();
  QL.require(c > 0.0,"positive compound factor required");
  QL.require(t > 0.0,"positive time required");
  double rate;
switch (comp) {
case Simple:
    rate=(c - 1) / t;
  break;
case Compounded:
rate=(Math.pow(c,(1 / (f * t))) - 1) * f;
break;
case Continuous:
rate=Math.log(c) / t;
break;
case SimpleThenCompounded:
if (t <= (1 / f)) {
rate=(c - 1) / t;
}
 else {
rate=(Math.pow(c,(1 / (f * t))) - 1) * f;
}
break;
default :
throw new LibraryException("unknown compounding convention");
}
return new InterestRate(rate,resultDC,comp,freq);
}

static public InterestRate impliedRate ( final double c , final double time , final DayCounter resultDC , final Compounding comp , final Frequency freq ) { final double t = time ; final double f = freq . toInteger ( ) ; QL . require ( c > 0.0 , "positive compound factor required" ) ; QL . require ( t > 0.0 , "positive time required" ) ; double rate ; switch ( comp ) { case Simple : rate = ( c - 1 ) / t ; break ; case Compounded : rate = ( Math . pow ( c , ( 1 / ( f * t ) ) ) - 1 ) * f ; break ; case Continuous : rate = Math . log ( c ) / t ; break ; case SimpleThenCompounded : if ( t <= ( 1 / f ) ) { rate = ( c - 1 ) / t ; } else { rate = ( Math . pow ( c , ( 1 / ( f * t ) ) ) - 1 ) * f ; } break ; default : throw new LibraryException ( "unknown compounding convention" ) ; } return new InterestRate ( rate , resultDC , comp , freq ) ; }
implied interest rate for a given compound factor at a given time . the resulting interestrate has the day - counter provided as input .
