//--------------------------------------------------------------------------- // Miranda Moore // COS488/MAT474 // Problem Set 10, Q3 //--------------------------------------------------------------------------- // The command "java Bitstring2" // plots the OGF for the set of bitstrings not containing the pattern // 0101010101. // // Dependencies: Complex.java, ComplexFunction.java, Plot2Dez.java //--------------------------------------------------------------------------- public class Bitstring2 implements ComplexFunction { // The OGF for bitstrings not containing 0101010101 public Complex eval(Complex z) { // {c(z) \over z^10+(1-2z)c(z)}, where c(z)=1+z^2+z^4+z^6+z^8 Complex one = new Complex(1, 0); Complex two = new Complex(2, 0); Complex squared = z.times(z); Complex fourth = squared.times(squared); Complex sixth = fourth.times(squared); Complex eighth = sixth.times(squared); Complex tenth = eighth.times(squared); Complex c = one.plus(squared).plus(fourth).plus(sixth).plus(eighth); return c.divides((one.minus(two.times(z))).times(c).plus(tenth)); } public static void main(String[] args) { Plot2Dez.show(new Bitstring2(), 512); } }