以下のようなコードを書いています。Bernoulli写像について、初期値や条件文を以下のように設定し実行したら、t+1=3から以下ずっと答えが0になってしまいました。何かプログラムに問題がありますでしょうか?
Java
1public class Bernoulli { 2 3 public static void main(String[] args) { 4 double[] x; 5 x = new double[1000]; 6 System.out.println(0 + "\t" + (Math.PI - 3)); 7 for (int t = 0; t < 20; t++) { 8 x[0] = Math.PI - 3; 9 if (x[t] < 0.5) { 10 x[t + 1] = 2 * x[t]; 11 12 if (0.5 <= x[t]) { 13 x[t + 1] = 2 * x[t] - 1; 14 15 } 16 } 17 18 System.out.println(t + 1 + "\t" + x[t + 1]); 19 } 20 21 } 22 23} 24
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。