プログラム倉庫

dがめ11

static double seekc(double[] tk,double startk){
double startc,c1,c2,c3;
int s;
double pp;
c1=0.1;
c2=10;
s=0;
while(s<50){
c3=(c1+c2)/2;
startc=c3;
pp=check(tk,startc,startk);
if(pp<50)c1=c3;
if(pp>50)c2=c3;
s=s+1;
}
return c1;
}
static double check(double[] tk,double startc,double startk){
int t,t1;
double pp;
double k1,cx,r1;
double a,beta;
a=0.33;
beta=0.95;
cx=startc;
k1=startk;
t=1;
pp=0;
while(t<200){
k1=k1+Math.pow(k1,a)-cx;
t1=t+1;
if (t1>100)t1=100;
r1=(1-tk[t1])*a*Math.pow(k1,a-1);
cx=cx*(beta*(1+r1));
if (k1<0)pp=100;
t=t+1;
}
return pp;
}
}