I'm new to notebooks and sympy. I have three questions. The notebook can be viewed here.
Is there any way to change the derivative notation? It would be nice if it were a little more compact in the output.
Is that \rightarrowx a bug?
Is there any way to get the raw LaTeX string? e.g. $f(x_0)^{2*x}$
I don't know. (edit: it seems not. Here is the implementation https://github.com/sympy/sympy/blob/master/sympy/printing/latex.py#L567 )
Yes, it is a bug. There should be a space between \rightarrow and x_0. (edit: it is fixed in the git version https://github.com/sympy/sympy/issues/10836)
Right-click -> Show Math As -> TeX Commands.
Related
When I am writing math equations in a markdown cell of a jupyter notebook, I casually put all of that in $ ... $. Today, I converted an .ipynb file to .tex, and realized most of these equations are converted into messy stuff in the output pdf. For instance, I realized it is converting all '$'s into '$'s.
This is an example of what has happened:
Jupyter Notebook markdown:
$ \nabla ^{2} f(x) = \frac{-1}{(x+1)^{2}} $
Tex Output:
\$ \nabla \^{}\{2\} f(x) = \frac{-1}{(x+1)^{2}} \$
Does anyone have any ideas why this is happening? Is there a better way to write down in-line math equations so that it is more compatible with LaTeX?
If you are eventually going to LaTeX version, the traditional advice is spelled out in minrk's comment from November 8 of 2012:
"The best solution for that right now would be to use 'raw' cells instead of markdown, and just type LaTeX as you would. Then use nbconvert to turn the ipynb to TeX (code, figures and all), and run latex to render that to PDF, etc. You don't get live-rendered TeX in the browser like you do with MathJax / Markdown, but you do still have TeX / code in one document."
The step where you are converting now is probably using nbconvert under the hood even if you aren't directly. (You may be using it directly since you tagged with 'nbconvert`.)
Alternatively, if you are going to LaTeX ultimately, you may want to use a code cell and use the LaTeX magic cell line at the start of that cell. See here and here about %%latex cell magic. (You'll note it is also mentioned among the StackOverflow thread I referenced earlier.) In regards to the %%latex cell magic, I suggest actually consulting the link that leads use in an example notebook in this post because it seems it has to be full-blown LaTeX code and not just simple equations that work easily elsewhere with just dollar signs bracketing them, i.e., MathJax.
I tried that option with your equation and when I output the notebook as LaTeX, I didn't see additional backslashes added. (I didn't however actually try rendering the LaTeX, and so I cannot address if all the cruft/boilerplate that Jupyter is adding causes any issues for downstream useability.)
Not sure if the answer here Jupyter notebook not printing underscores? is related:
The problem is not with Jupyter notebook but with the way the underscore is rendered in the example. The browser decided not to show the underscore for that particular resolution
... but here it goes: I try to enter the equation $$ \mathtt{A\_b} = \frac{A}{b} $$ in a Markdown cell in Jupyter notebook; and the rendering I get is this:
Don't know about you, but that looks like a dash/minus sign to me, not like an underscore.
So, how can I get a proper underline rendered in an equation in Jupyter notebook Markdown (where the equation is written as Latex, but rendered as MathML)?
Found a workaround - but I'd still love to hear a proper answer by someone who knows better ...
In the meantime - simply don't include the underscore inside \mathtt; that is, use:
$$ \mathtt{A}\_\mathtt{b} = \frac{A}{b} $$
... which results with:
I am new to jupyter notebooks, and I am trying to use juptyter notebooks to create lecture notes. I can figure out how to do equation numbering, but I don't know how to enable a theorem-proof environment like in latex. I looked online, but they all describe latex commands or at best equation numbering. Any help will be appreciated.
I have been using WxMaxima for my symbolic calculations for a while now. The good thing about WxMaxima is that you can get formatted outputs right in the program and then export them to LaTeX format with a click of the mouse.
Now I want to try the Jupyter/Ipython plus sympy for multiple reasons. I know how to use display(Math(r' some LaTeX math here ')) but what I want is to have the result/output of a cell in a nice mathematical form; something like the TraditionalForm[] command in Mathematica.
I would appreciate if you could help me know if/how I can get that right in a Jupyter notebook?
I think I found the proper solution and it is a sympy feature rather than Jupyter/IPython one. As explained here:
If all you want is the best pretty printing, use the init_printing() function. This will automatically enable the best printer available in your environment.
and
In the [Jupyter/]IPython notebook, it will use MathJax to render LATEX.
Then one can right click on the output and select Show Math As > Tex commands:
to get the LaTeX output.
P.S. A more proper formatting can be achieved via galgebra library. I will look into that and add it here later.
I want to set (x_1, x_2, \dots, x_n) in a bold font within R documentation. I wrote
\deqn(\bold{x}_1, \bold{x}_2, \ldots, \bold{x}_n),
but when Rstudio shows HTML preview of the documentation, x is not bold and \bold{x} is illustrated in HTML help page. The other latex math bold producer such as \boldsymbol, \mathbf, \boldmath were also unsuccessful.
So, What is the right command for setting a character in a bold within math mode?
Thank you,
P.S. When I applied \mathbf and \boldsymbol character x in pdf constructed documentation became bold, but how about the HTML help page?
Note: it is \deqn{ .. } but you've used '(...)'.
But then, the documentation (the "Writing R Extensions" manual that comes with every version of R and is also available on CRAN / r-project.org)
explains that both \deqn and \eqn are for layouting pure LaTeX and possibly give
(as 2nd argument) a text version of the corresponding formula.
Hence, \bold is not appropriate: It's Rd language instead of LaTeX.
Did you try \mathbf{} .. as that is the (pure) LaTeX way ?
HTML is conceptually between LaTeX and simple text (= the two arguments of (d)eqn).
Within R (and outside), there are efforts and experiments of better HTML rendering of such math equations. Do ask on R-help or R-devel (the mailing lists!) if you want to enquire about our plans about this ((I have not been involved in it)).
BTW: I strongly disagree with HW's opinion that you should not care about the PDF version of the reference manual. Mathematically minded authors and readers (with some experience) very much appreciate nice (formulas in) PDF versions of the help pages / reference manuals.
Yes, it is a matter of taste, to a large extent. I do prefer carefully written and layouted reference material to those help pages that are only written because they are required by "R CMD check" ;-)