<jupyter_start><jupyter_text>Exact solulution to the BID process  Solution of the BID process using the method of characteristics  Homogeneous equation Homogeneous PDE statisfied by the CGF.<jupyter_code>homcgfeqn (W) := diff(W, t) - 
    ((1 + sigma) / (2 * sigma)) * (z^2 - z) * diff(W, z) -
    ((1 - sigma) / (2 * sigma)) * (1 - z) * diff(W, z);<jupyter_output><empty_output><jupyter_text>ODE for characteristics of the generating function.<jupyter_code>chareqn(z) := diff(z, t) + ((1 + sigma) / (2 * sigma)) * (z^2 - z) +
    ((1 - sigma) / (2 * sigma)) * (1 - z);<jupyter_output><empty_output><jupyter_text>Expand the integrand for solving the characteristic equation as partial fractions.<jupyter_code>partfrac (-1 / (((1 + sigma) / (2 * sigma)) * (z^2 - z) +
    ((1 - sigma) / (2 * sigma)) * (1 - z)), z);<jupyter_output><empty_output><jupyter_text>From the implicit solution of the characteristic equation, obtain z and z0 explicitly.<jupyter_code>zsol : part(solve ([(z - (1 - sigma) / (1 + sigma)) / (z - 1) =
    %e^t * (z0 - (1 - sigma) / (1 + sigma)) / (z0 - 1)], [z]), 1, 2);
z0sol : part(solve ([(z - (1 - sigma) / (1 + sigma)) / (z - 1) =
    %e^t * (z0 - (1 - sigma) / (1 + sigma)) / (z0 - 1)], [z0]), 1, 2);<jupyter_output><empty_output><jupyter_text>Double check that the explicit solution indeed satisfied the ODE.<jupyter_code>factor(chareqn(zsol));<jupyter_output><empty_output><jupyter_text>Reorder the solution for z for the publication.<jupyter_code>factor(coeff(expand(num(zsol)), z0, 1)) * z0;
factor(coeff(expand(num(zsol)), z0, 0));
factor(coeff(expand(denom(zsol)), z0, 1)) *z0;
factor(coeff(expand(denom(zsol)), z0, 0));
newzsol :
((-(sigma + 1) + (1 - sigma) * %e^(-t)) * z0 +
    (1 - sigma) * (1 - %e^(-t))) /
(-(sigma + 1) * (1 - %e^(-t)) * z0 +
    1 - sigma - (1 + sigma) * %e^(-t));
factor(zsol - newzsol);<jupyter_output><empty_output><jupyter_text>Likewise, reorder the solution for z for typesetting.<jupyter_code>factor(coeff(expand(num(z0sol)), z, 1)) * z;
factor(coeff(expand(num(z0sol)), z, 0));
factor(coeff(expand(denom(z0sol)), z, 1)) *z;
factor(coeff(expand(denom(z0sol)), z, 0));
newz0sol : (((sigma - 1) * (1 - %e^(-t))
   + (1 - sigma - (1 + sigma) * %e^(-t)) * z) / 
    ((-1 - sigma + (1 - sigma) * %e^(-t)) + 
        (1 + sigma) * (1 - %e^(-t)) * z));
factor(z0sol - newz0sol);<jupyter_output><empty_output><jupyter_text>Check that the solution satsfies the PDE.<jupyter_code>factor(homcgfeqn(z0sol));<jupyter_output><empty_output><jupyter_text>Inhomogeneous equation Find characteristic passing through point $(t, z)$ parameterized by $t_p$.<jupyter_code>charz : factor(psubst([t = tp, z0 = z0sol], zsol));
subst(t, tp, charz);<jupyter_output><empty_output><jupyter_text>Pull off coefficients for typesetting.<jupyter_code>factor(coeff(num(charz), z, 0));
factor(coeff(num(charz), z, 1));
factor(coeff(denom(charz), z, 0));
factor(coeff(denom(charz), z, 1));<jupyter_output><empty_output><jupyter_text>Carry out the integral.<jupyter_code>block([indef],
    indef : integrate(charz - 1, tp),
    charint : logcontract (subst(t, tp, indef) - subst(0, tp, indef)));
part(charint, 1, 1, 1, 2, 1, 1, 2, 1);<jupyter_output><empty_output><jupyter_text>Re-express it for typesetting.<jupyter_code>logcontract(ev(
((2 * sigma) / (1 + sigma)) * 
    log((2 * sigma * %e^(-t)) /
        ((1 + sigma) * (1 - %e^(-t)) * z
        - 1 - sigma + (1 - sigma) * %e^(-t)))
        - charint,
    logexpand = super));<jupyter_output><empty_output><jupyter_text>Check that it satisfies the original CGF equation.<jupyter_code>factor(homcgfeqn(charint));<jupyter_output><empty_output><jupyter_text>Recovering the distribution  Homogeneous equation Re-express the generating function in a form that makes it easy to expand as a geometric series.<jupyter_code>apiece : factor(coeff(expand(num(z0sol)), z, 0) /
    coeff(expand(denom(z0sol)), z, 0));
bpiece : factor((coeff(expand(num(z0sol)), z, 1) * 
    coeff(expand(denom(z0sol)), z, 0) -
    coeff(expand(num(z0sol)), z, 0) * 
    coeff(expand(denom(z0sol)), z, 1)) / 
    coeff(expand(denom(z0sol)), z, 0)^2);
cpiece : factor(-coeff(expand(denom(z0sol)), z, 1) /
    coeff(expand(denom(z0sol)), z, 0));
factor(apiece + bpiece * z / (1 - cpiece * z)- z0sol);<jupyter_output><empty_output><jupyter_text>Re-express the generating function in a form that makes it easy to expand as a binomial series.<jupyter_code>psubst([t = 1.0, sigma = 0.2], [apiece, bpiece, cpiece]);
appi : factor(coeff(expand(num(z0sol)), z, 1) /
    coeff(expand(num(z0sol)), z, 0));
bppi : factor(-coeff(expand(denom(z0sol)), z, 1) /
    coeff(expand(denom(z0sol)), z, 0));
cppi : factor(coeff(expand(num(z0sol)), z, 0) /
    coeff(expand(denom(z0sol)), z, 0));
factor(cppi * (1 + appi * z) / (1 - bppi * z) - z0sol);<jupyter_output><empty_output><jupyter_text>Compute example numerical values of the Taylor series expansion of $z_0$<jupyter_code>psubst([sigma = 0.2, t = 1.0], taylor(newz0sol, z, 0, 6));<jupyter_output><empty_output><jupyter_text>Inhomogeneous equation<jupyter_code>inhmgfrac : 
((1 + sigma) * (1 - %e^(-t)) * z
        - 1 - sigma + (1 - sigma) * %e^(-t)) / 
    (2 * sigma * %e^(-t));
factor(coeff(expand(inhmgfrac), z, 0));
factor(-coeff(expand(inhmgfrac), z, 1));<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19587043000568288, 'fraction_numerical': 0.03030877060049252, 'mean_word_length': 4.6957928802588995, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '17', 'dir': 'jupyter-structured-clean-dedup', 'id': '211367', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2242, 'n_tokens_neox': 2133, 'n_words': 472, 'path': 'source/exact-solution/exact-solution.ipynb', 'repo_name': 'cameronraysmith/bid-analysis', 'size': '5279'}