public class tax{
public static void main(String[] args) {
int t;
double startk,startc;
double[] tk=new double[101];
for (t=1;t<101;t++){
tk[t]=0.2;
}
startk=10;
startc=start(tk,startk);
System.out.println(wel(tk,startk,startc));
System.out.println(bud(tk,startk,startc));
}
static double bud(double[] tk,double startk,double startc){
double k1,c1,r1,b1;
double a,beta,gov,tax,value;
int t;
b1=0;
a=0.33;
gov=0.05;
beta=0.95;
k1=startk;
c1=startc;
t=1;
value=1;
while(t<100){
tax=tk[t]*a*Math.pow(k1,a);
b1=b1+value*(tax-gov);
k1=k1+Math.pow(k1,a)-c1-gov;
r1=(1-tk[t+1])*a*Math.pow(k1,a-1);
value=value/(1+r1);
c1=c1*(beta*(1+r1));
t=t+1;
}
return b1;
}
static double wel(double[] tk,double startk,double startc){
double k1,c1,w1,r1;
double a,beta,gov;
int t;
w1=0;
a=0.33;
gov=0.05;
beta=0.95;
k1=startk;
c1=startc;
t=1;
while(t<100){
w1=w1+Math.pow(beta,t-1)*Math.log(c1);
k1=k1+Math.pow(k1,a)-c1-gov;
r1=(1-tk[t+1])*a*Math.pow(k1,a-1);
c1=c1*(beta*(1+r1));
t=t+1;
}
return w1;
}
static double start(double[] tk,double startk){
double c1,c2,startc;
double ch;
int s;
c1=0.1;
c2=10;
s=0;
while(s<30){
startc=(c1+c2)/2;
ch=check(tk,startk,startc);
if (ch<50)c1=startc;
if (ch>50)c2=startc;
s=s+1;
}
return c1;
}
static double check(double[] tk,double startk,double startc){
double a,gov,beta;
double c1,k1,r1;
int t,t1;
double ch;
gov=0.05;
a=0.33;
beta=0.95;
k1=startk;
c1=startc;
t=1;
ch=0;
while(t<200){
k1=k1+Math.pow(k1,a)-c1-gov;
if (k1<0)ch=100;
if (ch>50)t=300;
t1=t+1;
if (t1>100)t1=100;
r1=(1-tk[t1])*a*Math.pow(k1,a-1);
c1=c1*(beta*(1+r1));
t=t+1;
}
return ch;
}
}
最終更新:2010年01月23日 23:08