How to get a function that changes depending on x

  • Context: MHB 
  • Thread starter Thread starter tmt1
  • Start date Start date
  • Tags Tags
    Function
Click For Summary
SUMMARY

This discussion focuses on creating a piecewise function in LaTeX that changes its definition based on the value of x. The specific function discussed is defined as \( f(x) = \begin{cases} 2 - x & \text{if } x \leq 2 \\ x - 2 & \text{if } x > 2 \end{cases} \). Users are guided to utilize the "Begin/End" button for piecewise functions in the LaTeX Live Preview, and to use the Quick LaTeX element for symbol selection. This method streamlines the process of composing mathematical functions in LaTeX.

PREREQUISITES
  • Understanding of piecewise functions in mathematics
  • Familiarity with LaTeX syntax and environments
  • Knowledge of the LaTeX Live Preview tool
  • Ability to navigate the Quick LaTeX element for symbols
NEXT STEPS
  • Learn more about LaTeX environments for mathematical notation
  • Explore advanced LaTeX commands for formatting equations
  • Research additional types of functions that can be represented in LaTeX
  • Practice creating complex piecewise functions in LaTeX
USEFUL FOR

Mathematicians, educators, students, and anyone interested in typesetting mathematical functions using LaTeX.

tmt1
Messages
230
Reaction score
0
Hi,

I want to write a function whereby if x > 2 the function is one thing, and if x <= 2 it is something else.

How could I write this with latex?
 
Physics news on Phys.org
When you are composing your post, look below the posting area to the $\LaTeX$ Live Preview element. on the bottom row, you will see a button labeled "Begin/End" which will allow you to easily compose things using the begin/end environment, among these are piecewise functions.

So, click the "Begin/End" button, and then from the drop-down menu, choose "Piecewise Function" and then in the first input element, give the function's name, such as $f(x)$, and then in the other input element, define each function piece, and its domain, separated by a comma.

Once you have this defined, then click "Submission Options" and choose the tags with which you wish for the code to be wrapped, and whether you want this to be inserted in the live preview, or for it to replace what is there, then if you are finished, click "Submit/Close" and the code will be generated in the live preview, and it you like what you see, you can copy this code to your post message, at the current cursor location there using the "Copy to Post" button.

If you are not certain what $\LaTeX$ codes to use for your definitions, use the Quick $\LaTeX$ element to the right, from which you can choose the symbols you will need.
 
tmt said:
Hi,

I want to write a function whereby if x > 2 the function is one thing, and if x <= 2 it is something else.

How could I write this with latex?

How about this?

$\displaystyle \begin{align*} \left| 2 - x \right| = \begin{cases} 2 - x \textrm{ if } x \leq 2 \\ x- 2 \textrm{ if } x > 2 \end{cases} \end{align*}$

If you hover over the LaTeX you will see the code.
 
Prove It said:
How about this?

$\displaystyle \begin{align*} \left| 2 - x \right| = \begin{cases} 2 - x \textrm{ if } x \leq 2 \\ x- 2 \textrm{ if } x > 2 \end{cases} \end{align*}$

If you hover over the LaTeX you will see the code.

Thanks that is what I was looking for
 

Similar threads

Replies
5
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K