# Displaying equations using Tex

Discussion in 'Physics & Math' started by Pete, Dec 20, 2006.

1. ### PeteIt's not rocket surgeryModerator

Messages:
10,166
Good news, everyone!
Plazma has told me that we can now use $tags. Example: [indent][color=blue][noparse][tex]\frac{-b\pm\sqrt{b^2-4ac}}{2a}$[/noparse][/color][/indent]
Displays as:
$\frac{-b\pm\sqrt{b^2-4ac}}{2a}$​

I wonder if someone who is good at LaTex could write a short tutorial of the basics, with some common SciForums examples? I'll write one up myself, but I'm a complete beginner at LaTex so it will take a little while.

In the meantime, here's an external tutorial site: LaTex Math Tutorial for mimeTeX

Pete

Last edited: Nov 11, 2013
danshawen likes this.

3. ### James RJust this guy, you know?Staff Member

Messages:
30,130
Wow! This is a great idea. Thanks, Plazma!

Ok, basics of LaTeX, very briefly:

Grouping, where necessary, is done by enclosing expressions in curly brackets: {}

Superscripts and subscripts:

a^2 gives a superscript:
$a^2$
a_2 gives a subscript:
$a_2$
a^b_c does both:
$a^b_c$
Sometimes, grouping is necessary, as in a^{b+c}:
$a^{b+c}$

LaTeX functions are indicated by a backslash followed by the function name. For example \sin \int \pi gives:
$\sin \qquad \int \qquad \pi$

Greek letters are produced with a backslash and the letter name:
\alpha, \beta, \gamma, \phi
$\alpha, \beta, \gamma, \phi$

Fractions use the \frac function, with the numerator and denominator enclosed in curly brackets:
\frac{mc^2}{a + b + c^3}
$\frac{mc^2}{a + b + c^3}$

Sums and integrals can be produced as follows:
\int \limits_a^b 4x^2~dx
\sum \limits_{n=1}^4 n = 10
$\int \limits_a^b 4x^2~dx$
$\sum \limits_{n=1}^4 n = 10$

Note that a space is inserted in the integral above using a tilde (~).

Last edited: Dec 21, 2006
danshawen likes this.

5. ### AbsaneRocket SurgeonValued Senior Member

Messages:
8,989
Tex is short for LaTeX?

FREAKIN' SWEET! Now I just have to learn how to use it

7. ### quadraphonicsBloodthirsty BarbarianValued Senior Member

Messages:
9,391
Nice, but what's up with the automatic "x = " at the starting of every tex input?

$\frac{\partial}{\partial z} \int_{a(z)}^{b(z)} f(x,z) \, dx = \int_{a(z)}^{b(z)} \frac{\partial f}{\partial z} \, dx + f(b(z),z) \frac{\partial b}{\partial z} - f(a(z),z) \frac{\partial a}{\partial z}$

danshawen likes this.
8. ### James RJust this guy, you know?Staff Member

Messages:
30,130
Houston, we have a problem!

danshawen likes this.
9. ### quadraphonicsBloodthirsty BarbarianValued Senior Member

Messages:
9,391
Actually, Tex is a lower-level system that LaTex is built on top of, although it should be said that most people only use Tex in the context of LaTex.

10. ### D HSome other guyValued Senior Member

Messages:
2,257
TeX and LaTeX are not the same. TeX is a macro language designed by Donald Knuth back in the 1960s for writing technical papers with lots of math. LaTeX is a macro package for TeX and was written by Leslie Lamport back in the 1980s. Writing in plain TeX is a bear, plain and simple. LaTex makes writing a math paper a breeze.

Last edited: Dec 21, 2006
11. ### PeteIt's not rocket surgeryModerator

Messages:
10,166
Looks like a problem with the parsing of the $tag. The mimetex.cgi renderer is working, but "x=" is added to the front of the [tex] element content before being sent to the renderer. Plazma is notified! Pete$

12. ### cosmodelRegistered Senior Member

Messages:
62
test math

$\frac{-b\pm\sqrt{b^2-4ac}}{2a}$

13. ### AbsaneRocket SurgeonValued Senior Member

Messages:
8,989
$\gamma = \lim_{n \rightarrow \infty } \left( \left( \sum_{k=1}^n \frac{1}{k} \right) - \ln (n) \right)=\int_1^\infty\left({1\over\lfloor x\rfloor}-{1\over x}\right)\,dx$

My favorite constant.

14. ### James RJust this guy, you know?Staff Member

Messages:
30,130
Ok, looks like the problem is fixed now.

I'm excited, people! Ooh, maths. It makes me go all gooey inside.

15. ### AbsaneRocket SurgeonValued Senior Member

Messages:
8,989
Hrm. Does the TeX display incorrectly for IE or is it just this machine I am on (computer at school)? Some of the commands don't show right here (like in my Gamma constant equation, I see 1/[\overx?] instead of 1/x in Tex.

16. ### James RJust this guy, you know?Staff Member

Messages:
30,130
The space is important after the \over command.
It should be

1 \over x

which comes out as:

$1 \over x$

Or, you can use \frac:

\frac{1}{x}

is displayed as

$\frac{1}{x}$

17. ### PeteIt's not rocket surgeryModerator

Messages:
10,166
Thanks to Plazma for having the bug corrected.

Should we leave this thread stickied, or just link to it in the FAQ?

18. ### James RJust this guy, you know?Staff Member

Messages:
30,130
Leave it sticky for now, I think.

19. ### AbsaneRocket SurgeonValued Senior Member

Messages:
8,989
Well, the code produces the correct equations from my computer. However, it does not output everything from my school's computer. Maybe they are just too old.

20. ### invert_nexusZe do caixaoValued Senior Member

Messages:
9,686
Makes me wish I was a mathematician...

21. ### Blue_UKDrifting MindValued Senior Member

Messages:
1,446
I haven't returned to sciforums in ages - I'm glad to see that James and Pete are still about and more glad to see that someone has made an equation editor for bb code.

Absane, could you explain that constant? I can't grasp it! Surely as x approaches inf. then ln(x) also approaches something high too?

$\int{\frac{2x}{x^2}} = ln(x^2)$

22. ### James RJust this guy, you know?Staff Member

Messages:
30,130
Yes, but infinity minus infinity can be finite.

23. ### AbsaneRocket SurgeonValued Senior Member

Messages:
8,989
I don't have a proof that the series converges, but I am sure that it is not too hard.

It goes something like this:

1 - ln(1) = 1
1 + 1/2 - ln(2) = 0.806852819
1 + 1/2 + 1/3 - ln(3) = 0.734721045

1 + 1/2 + 1/3 + ... + 1/100 - ln(100) = 0.582207331651

The series converges to 0.5772156649...

No one knows if this number is irrational. According to Mathworld, "The famous English mathematician G. H. Hardy is alleged to have offered to give up his Savilian Chair at Oxford to anyone who proved gamma to be irrational"

http://mathworld.wolfram.com/Euler-MascheroniConstant.html

But this series is a perfect example as to why we cannot assume infinity - infinity = 0 or any other number for that matter.