How to get a function that changes depending on x

  • MHB
  • Thread starter tmt1
  • Start date
  • Tags
    Function
In summary, you can write a function whereby if x > 2 the function is one thing, and if x <= 2 it is something else by defining each function piece and its domain using a comma.
  • #1
tmt1
234
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
  • #2
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.
 
  • #3
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.
 
  • #4
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
 
  • #5


To write this function in LaTeX, you can use the "piecewise" function, which allows you to specify different expressions for different intervals of the variable x. Here is an example of how you can write this function:

$f(x) = \begin{cases} 2x+1 & \text{if } x > 2 \\ x^2+3 & \text{if } x \leq 2 \end{cases}$

In this example, the function has two different expressions depending on the value of x. If x is greater than 2, the function is equal to 2x+1. If x is less than or equal to 2, the function is equal to x^2+3. You can change the expressions to fit your specific function.
 

FAQ: How to get a function that changes depending on x

What is a function?

A function is a mathematical relationship between two quantities, usually represented by an equation, in which one quantity depends on the other. It maps an input value, known as the independent variable, to an output value, known as the dependent variable.

How can I create a function that changes depending on x?

To create a function that changes depending on x, you can use the notation f(x) to represent the function and then define the relationship between x and the output variable. This can be done using algebraic equations, graphs, or tables.

What is the role of x in a function?

The variable x is known as the independent variable in a function. It represents the input or the value that is being manipulated in order to produce an output value. The value of x can be changed, which will result in a different output value, thus making the function change depending on x.

How do I know if a function changes depending on x?

A function changes depending on x if the output value varies as the input value, x, changes. This can be observed by plotting the function on a graph and noticing any shifts or changes in the shape of the graph as x changes. Additionally, if the equation of the function contains variables and the output value changes as these variables change, then the function is dependent on those variables.

Can a function change depending on multiple variables?

Yes, a function can change depending on multiple variables. These functions are known as multivariable functions and have more than one independent variable. The output value of a multivariable function depends on the values of all the independent variables, and changes in any of these variables will result in a change in the output value.

Similar threads

Replies
8
Views
2K
Replies
2
Views
1K
Replies
13
Views
2K
Replies
8
Views
2K
Replies
1
Views
1K
Replies
3
Views
2K
Replies
4
Views
2K
Back
Top