Quantcast
Channel: MobileRead Forums
Viewing all articles
Browse latest Browse all 46786

Problem with math equations

$
0
0
Hello,

I've tried to make an epub from a website using calibre so I can read it offline. The website containts a lot of math and equations. Now, my problem is that calibre shows some of the math but not all of them, and i dont mean that it shows them twisted or unformated but not at all. Also when i press F5 to refresh the ebook the reader displays "Typesetting Math" and loads from 0% to 100%. at around 20-50% the math types are beeing displayed but when it reaches 100% they disapear again. I have included below some text with math equations. the first usualy works and the second usualy doesnt get displayed.


Code:

<p>Now we can define <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>X</mi><mo stretchy="false">)</mo></math></span><script id="MathJax-Element-18" type="math/tex">h_\theta(X)</script> as a row vector that gives the value of <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></math></span><script id="MathJax-Element-19" type="math/tex">h_\theta(x)</script> at each of the <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>m</mi></math></span><script id="MathJax-Element-20" type="math/tex">m</script> training examples:</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mtable minlabelspacing=".8em" side="right" displaystyle="true" columnspacing="0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em" rowspacing="3pt" columnalign="right left right left right left right left right left right left"><mtr><mtd><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>X</mi><mo stretchy="false">)</mo><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mi>n</mi></msub><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="3em"/><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mi>n</mi></msub><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="3em"/><mo>.</mo><mo>.</mo><mo>.</mo><mspace width="3em"/><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mi>n</mi></msub><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr></mtable></mfenced></mtd></mtr></mtable></math></span><script id="MathJax-Element-21" type="math/tex">
\begin{align*}
h_\theta(X) =
\begin{bmatrix}
\theta_0 x^{(1)}_0 + \theta_1 x^{(1)}_1 + ... + \theta_n x^{(1)}_n \hspace{3em}
\theta_0 x^{(2)}_0 + \theta_1 x^{(2)}_1 + ... + \theta_n x^{(2)}_n \hspace{3em} ... \hspace{3em}
\theta_0  x^{(m)}_0 + \theta_1 x^{(m)}_1 + ... + \theta_n x^{(m)}_n \newline
\end{bmatrix}
\end{align*}
</script></p>
<p>But again using the definition of matrix multiplication, we can represent this more concisely:</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mtable minlabelspacing=".8em" side="right" displaystyle="true" columnspacing="0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em" rowspacing="3pt" columnalign="right left right left right left right left right left right left"><mtr><mtd><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>X</mi><mo stretchy="false">)</mo><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub><mspace width="2em"/><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub><mspace width="2em"/><mo>.</mo><mo>.</mo><mo>.</mo><mspace width="2em"/><msub><mi mathvariant="italic">θ</mi><mi>n</mi></msub></mtd></mtr></mtable></mfenced><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><mo>.</mo><mo>.</mo><mo>.</mo><mspace width="2em"/><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr><mtr><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><mo>.</mo><mo>.</mo><mo>.</mo><mspace width="2em"/><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr><mtr><mtd><mo stretchy="false">⋮</mo></mtd></mtr><mtr><mtd><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><mo>.</mo><mo>.</mo><mo>.</mo><mspace width="2em"/><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr></mtable></mfenced><mo stretchy="false">=</mo><msup><mi mathvariant="italic">θ</mi><mi>T</mi></msup><mi>X</mi></mtd></mtr></mtable></math></span><script id="MathJax-Element-22" type="math/tex">
\begin{align*}
h_\theta(X) =
\begin{bmatrix}
\theta_0 \hspace{2em}  \theta_1 \hspace{2em} ... \hspace{2em} \theta_n
\end{bmatrix}
\begin{bmatrix}
x^{(1)}_0 \hspace{2em} x^{(2)}_0\hspace{2em}  ... \hspace{2em} x^{(m)}_0 \newline
x^{(1)}_1 \hspace{2em} x^{(2)}_1 \hspace{2em} ... \hspace{2em} x^{(m)}_1 \newline
\vdots \newline
x^{(1)}_n \hspace{2em} x^{(2)}_n \hspace{2em} ... \hspace{2em} x^{(m)}_n \newline
\end{bmatrix}=
\theta^T X
\end{align*}
</script></p>
<p><strong>Note</strong>: this version of the hypothesis function assumes the matrix <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>X</mi></math></span><script id="MathJax-Element-23" type="math/tex">X</script> and vector <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="italic">θ</mi></math></span><script id="MathJax-Element-24" type="math/tex">\theta</script> store their values as follows:</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mtable minlabelspacing=".8em" side="right" displaystyle="true" columnspacing="0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em" rowspacing="3pt" columnalign="right left right left right left right left right left right left"><mtr><mtd><mi>X</mi><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>3</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr><mtr><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>3</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr></mtable></mfenced></mtd><mtd><mo stretchy="false">,</mo><mi mathvariant="italic">θ</mi><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub></mtd></mtr><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub></mtd></mtr></mtable></mfenced></mtd></mtr></mtable></math></span><script id="MathJax-Element-25" type="math/tex">
\begin{align*}
X =
\begin{bmatrix}
x^{(1)}_0  x^{(2)}_0  x^{(3)}_0  \newline
x^{(1)}_1  x^{(2)}_1  x^{(3)}_1
\end{bmatrix}

,\theta =
\begin{bmatrix}
\theta_0 \newline
\theta_1 \newline
\end{bmatrix}
\end{align*}
</script></p>
<p>You might instead store the training examples in <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>X</mi></math></span><script id="MathJax-Element-26" type="math/tex">X</script> row-wise, like such:</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mtable minlabelspacing=".8em" side="right" displaystyle="true" columnspacing="0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em" rowspacing="3pt" columnalign="right left right left right left right left right left right left"><mtr><mtd><mi>X</mi><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr><mtr><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr><mtr><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>3</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>3</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr></mtable></mfenced></mtd><mtd><mo stretchy="false">,</mo><mi mathvariant="italic">θ</mi><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub></mtd></mtr><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub></mtd></mtr></mtable></mfenced></mtd></mtr></mtable></math></span><script id="MathJax-Element-27" type="math/tex">
\begin{align*}
X =
\begin{bmatrix}
x^{(1)}_0  x^{(1)}_1  \newline
x^{(2)}_0  x^{(2)}_1  \newline
x^{(3)}_0  x^{(3)}_1
\end{bmatrix}

,\theta =
\begin{bmatrix}
\theta_0 \newline
\theta_1 \newline
\end{bmatrix}
\end{align*}
</script></p>


Code:

<h2 id="uKMKRwShqcolDYwBCCqBGWG"> <span class="mw-headline" id="Hypothesis_Representation">Hypothesis Representation</span></h2>
<p>Our hypothesis should satisfy:</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathsize="1.2em"><mn>0</mn><mo stretchy="false">≤</mo><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo stretchy="false">≤</mo><mn>1</mn></mstyle></math></span><script id="MathJax-Element-4" type="math/tex">
\large
0 \leq h_\theta (x) \leq 1
</script></p>
<p>Our new form uses the "Sigmoid Function," also called the "Logistic Function":</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathsize="1.2em"><mtable minlabelspacing=".8em" side="right" displaystyle="true" columnspacing="0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em" rowspacing="3pt" columnalign="right left right left right left right left right left right left"><mtr><mtd/><mtd><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo stretchy="false">=</mo><mi>g</mi><mo stretchy="false">(</mo><msup><mi mathvariant="italic">θ</mi><mi>T</mi></msup><mi>x</mi><mo stretchy="false">)</mo></mtd></mtr><mtr><mtd/></mtr><mtr><mtd/><mtd><mi>z</mi><mo stretchy="false">=</mo><msup><mi mathvariant="italic">θ</mi><mi>T</mi></msup><mi>x</mi></mtd></mtr><mtr><mtd/><mtd><mi>g</mi><mo stretchy="false">(</mo><mi>z</mi><mo stretchy="false">)</mo><mo stretchy="false">=</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>1</mn><mrow><mn>1</mn><mo stretchy="false">+</mo><msup><mi>e</mi><mrow><mo stretchy="false">−</mo><mi>z</mi></mrow></msup></mrow></mfrac></mstyle></mtd></mtr></mtable></mstyle></math></span><script id="MathJax-Element-5" type="math/tex">
\large
\begin{align*}
 h_\theta (x) =  g ( \theta^T x ) \newline \newline
 z = \theta^T x \newline
 g(z) = \dfrac{1}{1 + e^{-z}}
\end{align*}
</script></p>

Do you guys have any idea why is this happening? Thank you!!!

Viewing all articles
Browse latest Browse all 46786

Trending Articles