0

I am doing my homework using Jupyter Notebook Extension and Sympy module of Python in VS Code. I am trying to render equations in Latex font, but it does not work as I imagined. Is there anybody who can guess what the problem would be? I have added captured images related to the problem.

I am using

  • VS Code 1.52
  • Jupyter Notebook Extension v2020.12.414227025
  • Python Extension v2020.11.371526539

Thank you and have a nice Sunday!

When I type random equation like below, it is displayed in this style

However when I type in certain equation that I found online, then it is displayed in proper Latex font.

2 Answers 2

0

That is the correct LaTeX output for that expression. That is the result of the integral displayed in terms of the hypergeometric function:

https://en.wikipedia.org/wiki/Generalized_hypergeometric_function

You might not recognise the function but it is an ordinary mathematical function and you can substitute values into is and evaluate it etc:

In [17]: antiderivative = integrate(Si(x)/x, x)

In [18]: antiderivative
Out[18]: 
       ⎛              │   2 ⎞
   ┌─  ⎜   1/2, 1/2   │ -x  ⎟
x⋅ ├─  ⎜              │ ────⎟
  2╵ 3 ⎝3/2, 3/2, 3/2 │  4  ⎠

In [19]: antiderivative.subs(x, 1)
Out[19]: 
 ┌─  ⎛   1/2, 1/2   │     ⎞
 ├─  ⎜              │ -1/4⎟
2╵ 3 ⎝3/2, 3/2, 3/2 │     ⎠

In [20]: antiderivative.subs(x, 1).n()
Out[20]: 0.981810799391358

Many ordinary looking mathematical functions can be expressed in terms of hypergeometric functions and sometimes it is possible to simplify them into something more recognisable:

In [27]: hyper([], [S(1)/2], -x**2/4)
Out[27]: 
     ⎛    │   2 ⎞
 ┌─  ⎜    │ -x  ⎟
 ├─  ⎜    │ ────⎟
0╵ 1 ⎝1/2 │  4  ⎠

In [28]: hyperexpand(_)
Out[28]: cos(x)

It is useful to be able to rewrite an integral in terms of hypergeometric functions because a routine that can integrate hypergeometric functions can work for a wide variety of possible integrands. It is particularly use for special functions (such as Si) without needing special rules for each new function that we might want to integrate. SymPy has a specific integration routine meijerg which does this using the even more general Meijer G function:

https://en.wikipedia.org/wiki/Meijer_G-function

SymPy has used the meijerg routine for this integral although it looks like the result has been converted to hypergeometric functions rather than G functions. Sometimes it is possible to simplify the result of a definite integral even if it is computed using an antiderivative that can only be expressed in terms of hypergeometric/G functions.

In the case of this integral though it doesn't look like SymPy can express it using other functions. I checked WolframAlpha as well which gives a less simple (but equivalent) representation in terms of hypergeometric functions as well:

https://www.wolframalpha.com/input/?i=integrate+Si%28x%29%2Fx

Sign up to request clarification or add additional context in comments.

1 Comment

Oh of course! I should have looked more carefully
0

I don't know why you've got two different types of output (Unicode and LaTeX), but I can tell you how you can be sure that the LaTeX rendering is the unfailing default

from sympy import *
init_printing(use_latex=True)
...

1 Comment

I have tried this method but it does not work either ;( But thanks guys for your kind helps guys!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.