TransWikia.com

max and superscript problems in equation

TeX - LaTeX Asked by manuferpi on July 31, 2021

I need to display this equation:
enter image description here

But I keep getting the following:

enter image description here

I do not know how to make the subscript in the max function and the superscript to end.
Here is my code:

begin{equation*}

Q(s,a) leftarrow Q(s,a)+alpha left( r+ gamma max_{{a^'}in{A}} Q(s^',a^')-Q(s,a)right)

end{equation*}

4 Answers

Use this much simpler code, and you'll have no problem. Note it's better to control the size of the parentheses here with the pair Bigl( … Bigr) rather than left( … right).

begin{equation*}
Q(s,a) leftarrow Q(s,a)+alpha Bigl( r+ gamma max_{a' in A } Q(s',a') - Q(s,a)Bigr)
end{equation*}

enter image description here

Correct answer by Bernard on July 31, 2021

Try this:

Q(s,a) leftarrow Q(s,a) + alpha Big ( r + gamma mathop{text{max}}_{a' in A} Q(s',a') - Q(s,a) Big )

Answered by Gnoppi on July 31, 2021

Use limits to put some text or math below max

Here is the code which you can try

documentclass{article}
usepackage{amsmath}

begin{document}

begin{align*} 
Q(s,a) leftarrow Q(s,a)+alpha,left(r+ gamma maxlimits_{a',in, A},Q(s',a')-Q(s,a)right)
end{align*}

end{document}

enter image description here

Answered by Tanvir on July 31, 2021

The most important protip for using LaTeX:

When your compiler shows you errors: read the errors and try to resolve them.

The reason that your code generated odd output is because LaTeX encountered an error in your code and did its best to guess what you meant. Frequently the guess is wrong, and so you get the wrong output.

Now, to the error: your compilation should've shown something like

l.5 ...w Q(s,a)+alpha left( r+ gamma max_{{a^'
                                                  }in{A}} Q(s^',a^')-Q(s,a)r...

this tells you that when LaTeX read up to the prime sign ' it encountered an error. The error is because that the sign ' is already in superscript mode when used in mathematics. If you try to put ^' this is a double superscript and causes an error.

So all you need to do is to remove the doubling. Instead of a^', type a' and this will give you the correct output.

Answered by Willie Wong on July 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP