How to compile latex equations in markdown with Pandoc? - latex

I am having trouble compile markdown files with latex equation using Pandoc. The code is the following:
+ Regression Specification:
+ $y_{gpt} = \alpha+\beta_1 * Parallel+ \gamma * Prov_p+ \delta *
Year_t+\epsiolon_{gpt}$
I get an undefined control sequence error.

You had a typo in \epsilon, this works:
+ Regression Specification:
+ $y_{gpt} = \alpha+\beta_1 * Parallel+ \gamma * Prov_p+ \delta *
Year_t+\epsilon_{gpt}$
(btw. not sure why you have those plus sings at the beginning: they produce an ordered list which seems odd in this context.)

Related

How to line break long equation in overleaf keeping both lines left sided, and keeping font-size as well?

My tries:
1st example: I didn't find how to fix the problem with th font size using \begin{array}.
Code:
\begin{equation}
\begin{array}{l}
\frac{\partial \rho}{\partial t}=-R_{z} \cos \delta_{E} \frac{\partial \delta_{E}}{\partial t}-R_{s}\left[-\sin \delta_{E} \frac{\partial \delta_{E}}{\partial t} \cos (\omega t+\lambda-\alpha_{E})+\right. \\
\left.-\cos \delta_{E} \sin \left(\omega t+\lambda-\alpha_{E}\right)\left(\omega-\frac{\partial \alpha_{E}}{\partial t}\right)\right]
\end{array}
\end{equation}
2nd example: Using \begin{split} I didn't find the way the to put second line on the left side.
Code:
\begin{equation}
\begin{split}
\frac{\partial \Dot{\rho}}{\partial\omega} = -R_{s}A[ A\omega t(\cos{\phi})^2\sin{\delta_{E}}\cos{(\lambda - A\sin{\omega t})} - \omega t\sin{\phi}\sin{(\lambda - A\sin{\omega t})} +\\+ \sin{(\lambda - A\sin{\omega t})}\cos{phi}] - R_{s}At\cos{\phi}\sin{\delta_{E}}\sin{(\lambda - A\sin{\omega t})}
\end{split}
\end{equation}
Output of the code.
I also will appreciate a lot if somebody will tell me, that there is a magic command that breaks equation in lines automatically (without manually inserting '\')
My favourite way to do this is outlined in section 3.5.2 of lshort.
For the sake of everyone, it requires the IEEEtrantools package.
The code cited in the sources stated is the following:
\begin{IEEEeqnarray}{rCl}
a & = & b + c\\
& = & d + e + f + g + h + i + j + k \nonumber\\
&& \negmedspace {} + l + m + n + o\\
& = & p + q + r + s
\end{IEEEeqnarray}
Giving the result
Which you and others should be able to adapt appropriately for their own use case.
The environment defines columns within the equation, which in this case has a right aligned column, followed by centre aligned, followed by left aligned using {rCl}.
Note also that generally only one binary operation is used on the second line of a overflowing equation.
And I feel that \cos{phi} in the second equation is meant to really be \cos\phi as it is elsewhere in your equations.

Quadratic cost using np linalg norm doesn't work

Why does this line:
prog.AddQuadraticErrorCost(np.identity(len(q)), q0, q)
works.
But this:
prog.AddCost(np.linalg.norm(q_variables - q_nominal)**2)
RuntimeError: Expression pow(sqrt((pow(q(0), 2) + pow(q(2), 2) +
pow(q(4), 2) + pow(q(6), 2) + pow(q(7), 2) + pow(q(8), 2) + pow((-1 +
q(5)), 2) + pow((-0.59999999999999998 + q(1)), 2) + pow((1.75 + q(3)),
2))), 2) is not a polynomial. ParseCost does not support
non-polynomial expression.
does not?
Are the expressions not mathematically identical?
They are mathematically identical, but our symbolic engine is not yet powerful enough to recognize that sqrt(x)**2 should be simplified as x.
You can also write the expression using the symbolic form
prog.AddQuadraticCost((q-q0).dot(q-q0))
if you prefer readable code.

Maxima numerical integration syntax

I'm trying to obtain a numerical solution to the following integral:
1
The correct answer is -0.324 + 0.382i but as seen below I am not getting a numerical answer and would appreciate help with the Maxima syntax.
2
Perhaps related to why I am not getting a numerical output are two specific questions:
I read that e and i in Maxima need to be preceded by % in input but should these also appear as %e and %i as seen in the Maxima output?
Why is dy missing at the end of the integral in the Maxima output?
Thank you!
Looks to me like your input is okay, however, the function to compute approximations to integrals is named quad_qags. (There are actually several related functions. See ?? quad_ for more info.) Also, a wrinkle here is that the integrand is a complex-valued function (of a real variable), and quad_qags can only work on real-valued integrands, so we'll have to work around it. Here's how I would arrange it.
myintegrand: exp(%i*(1 + %i*y))/(1 + %i*y + 1/(1 + %i*y));
result_realpart: quad_qags (realpart (myintegrand), y, 0, 6);
result_imagpart: quad_qags (imagpart (myintegrand), y, 0, 6);
result: result_realpart[1] + %i*result_imagpart[1];
I get 0.3243496676292901*%i + 0.3820529930785175 as the final result. That's a little different from what you said; maybe a minus sign went missing? or there's a missing or extra factor of %i?
A quick approximation
0.1 * lsum (x, x, float (rectform (makelist (ev (myintegrand, y = k/10), k, 0, 60))));
seems to show the result from quad_qags is reasonable.

Can you pass your own weights to skimage.color.rgb2gray?

The documentation page for skimage.color.rgb2gray says:
The weights used in this conversion are calibrated for contemporary CRT phosphors:
Y = 0.2125 R + 0.7154 G + 0.0721 B
Suppose I want to use my own weights such that Y = Wr * R + Wg * G + Wb * B. Is there a way of passing an array like [Wr, Wg, Wb] to rgb2gray so it uses that instead?
Currently there is no way of doing that, but since the channels are the last axis on the array, it's actually easy to do this with matrix multiplication:
Y = image # [Wr, Wg, Wb]
So you could very easily write your own (or use this one-liner directly).
(Note: in Python 3.4 or earlier, you would instead use np.dot(image, [Wr, Wg, Wb]).)

Maximal path problem

Given oriented unweighted graph and the problem is to find simple path of maximal length
(start vertex and end vertex are not fixed). It obviously can be solved in O(n^2 * 2 ^n) but I heard that there is O(n * 2 ^ n) algorithm which I don't know. So how to solve it in O(n * 2 ^n)? //n = |V|
If your problem really is the Longest Path Problem on a DAG, the algorithm from Wikipedia is below and runs in O(|V| + |E|):
algorithm dag-longest-path is
input:
Directed acyclic graph G
output:
Length of the longest path
length_to = array with |V(G)| elements of type int with default value 0
for each vertex v in topOrder(G) do
for each edge (v, w) in E(G) do
if length_to[w] <= length_to[v] + weight(G,(v,w)) then
length_to[w] = length_to[v] + weight(G, (v,w))
return max(length_to[v] for v in V(G))

Resources