# Questions tagged [piecewise]

Questions about the Piecewise function, which is represented by different expressions for different ranges of values of its independent variable.

315 questions
Filter by
Sorted by
Tagged with
95 views

### Priority of nested function in Mathematica

I am facing a small problem with the nested function in Mathematica. Please take a look at the attached Code below. ...
141 views

### UnitStep vs HeavisideTheta; KroneckerDelta vs DiscreteDelta

What are the differences between these pairs of functions? In many cases, they seem to act the same. For example, both DiscreteDelta and ...
131 views

### Does Mathematica have this function implemented?

Is there a function in Mathematica that can express a piecewise function in terms of the Heaviside theta function? Say, for example, the solution to this ODE.
269 views

### NDSolve with Piecewise function

I have the following code on Mathematica ...
152 views

### Defining a piecewise function with underlying lattice

I'm fairly new to Mathematica, and programming in general, but I'm trying to define an $n$-dimensional piecewise function, $F({\bf x})$. Properties of the function are set by an underlying lattice, ...
144 views

### FindRoot when variable is inside a piecewise function

I want to find the root of a function that has a piecewise part. This means that the value Mathematica will search will determine in which piece of the function we will be. I don't my example is the ...
120 views

### Unfamiliar output of FullSimplify [duplicate]

I got the following output of FullSimplify, when expecting to get "0". I found no explanation of this output here. Could you please explain, what it means? That my expression equals zero when the ...
38 views

### Unexpected behavior when copying a Piecewise expression

When I type a Piecewise function (e.g. Piecewise[{{a,0<a<1},{2a,1<a<2}}]) in mathematica notebook using ...
2k views

### How to plot a list to look like step function?

Suppose I have the following simple list. l = {0,2,5,9,14}; I want to to make a plot that looks like the figure below. I.e. I want to have a horizontal line ...
217 views

### Restricting a plot to be over integers

I am trying to plot the following function: ...
218 views

### ContourPlot combined with Piecewise bug

I'm plotting a two dimensional von Mises and Tresca yield surface and got: ...
51 views

### Strange behavior of NIntegrate

I have some function f[x,y,a], where a is some parameter, defined as piecewise f[x,y,a] = Piecewise[{{g[x,y,a], a<m[x]}, {0, True}}] Here $m$ is some function....
642 views

### What does True mean in this case? [duplicate]

I use the following code to find the expansion for small $x$: ...
263 views

### set colours for different parts of a piecewise function's graph [duplicate]

I would like to create a graph of the piecewise function $f(x) = \begin{cases} x + 2, & x < -1 \\ x^2, & -1 \leq x \leq 2 \\ 3, & x > 2\end{cases}$ where the changes in the ...
84 views

### I get gaps when use Plot3D combined with Piecewise [closed]

I am trying to plot a function that is Piecewise in both dimensions. I write this ...
101 views

### Simplify integral with piecewise expression

How can I simplify this integral? Integrate[Piecewise[{{c[x], 0 <= x <= 1/2}, {0, True}}], {x, 0, 1}] I think it should be the same as ...
161 views

### Plotting orbit of a discontinuous map

I'm trying to plot the orbit of a two dymensional discontinuous map. Could you help me please? I tried using Piecewise, but I didn't get the result I wanted. The ...
304 views

### Force derivative of piecewise function at boundary points to be one-sided derivative

I've defined a smooth step function given as f[x_] = Piecewise[{ {y0, x<x0-dx/2}, {y0+1/2(y1-y0)(1-Cos[Pi*x/dx]), x<x0+dx/2}, {y0, True} }]; ...
427 views

105 views

### PiecewiseExpand fails with min of two piecewise functions

I have two Piecewise functions that are (in this case) just the empirical CDFs of two sets of data: ...
501 views

### Most efficient way to integrate a linear piecewise function

I am having a lot of trouble integrating a simple function. Here's the context: I generate data from two distributions, and I want to calculate the overlap coefficient of representing those datasets ...
105 views

### Piecewise and ProbabilityDistribution malfunction when used together

Yesterday I opened this question, what had a happy end after all. But when I tried to model more complex discrete random variables using Piecewise instead of ...
87 views

### Piecewise integration fail or something else?

I have a not-so-complicated piecewise cubic function, shown below as the yellow curve on the right. It's derivative is on the left; the blue lines are references. Please see the code below where I ...
87 views

### Difference in Piecewise function

I have two piecewise functions that are defined on values of [0,200]. I would like to find out the maximum difference between the two values. The usual Max[] function does not work because all values ...
225 views

### Piecewise function created from list

I have a list of values called EDFh3. This contained values which are partitioned by 3 where it is in the format ...
228 views

### How to implement a loop inside Piecewise?

I wanna be able to use the Piecewise function such that I don't have to manually enter all the pieces. For example, say I define f[x_]:={x,x^2,x^3} Consider now ...
124 views

### DSolve, Simultaneous Eqns + Piece-wise + boundary and initial conditions

mathematica noobie here but could really use some help. So I have 2 sets of equations: 1) w''''[x]=0 and 2) w''''[x]=q[x] 1) has conditions w[0]=0, w'[0]=0 2) has conditions w''[1]=0, w'''[1]=0 1) ...
271 views

### Plot of piecewise function is not bounded properly

I am trying to plot a piecewise function that gets bounded above and below a certain value (e.g). ...
103 views

### Selecting only list of function output from piecewise function output [closed]

Say I have a piecewise function: V[m_] := Piecewise[{{(1 + m)^2, m >= 1}, {Log[m], m < 1}}] And I input a large list of ...
2k views

### Plotting a piecewise function [closed]

I'm having trouble plotting the piecewise function below. The only way I can replicate this function is using ...
324 views

### How do I insert a circle inside another circle with Piecewise?

I need to create two circles, where one circle is inside the other using the Piecewise function. So far I have ...
223 views

### Variable Increments in a Table

I am working on a problem involving the piecewise function: $$x^2 \quad \mbox{if } \quad x < 2$$ $$(x-3)/(\sqrt{x-2}-1) \quad \mbox{if } \quad x \geq 2$$ I am supposed to find ...
131 views

### How I can define this staircase function?

I have a function $f:[-1,1]\to\Bbb R$ defined by f(x):=\begin{cases}\frac1{n+2},&x\in\left[-\frac1n,-\frac1{n+1}\right)\cup\left(\frac1{n+1},\frac1n\right]\\0,&\text{otherwise}\end{cases}\...
67 views

### Can i use PiecewiseExpand to expand If statements with function arguments?

Usually PiecewiseExpand[] is able to convert If[] statements to Piecewise functions, e.g. <...
120 views

### Interpretation of HeavisideTheta Integration Output

I need to integrate integrals of the type Integrate[Boole[2 k*q >= Absolute[p^2 - k^2 - q^2]], q] where $q$, $k$, and $p$ go from $0$ to $1$. To learn to ...
237 views

### How to write a piecewise function to take a list of {value,point} as its parameter?

I want to apply Piecewise function to a list of range and values, for example, to make f[{{v1,r2},{v2,r2},{v3,r3},{v4,r4},...,{vn,\[Infinity]}}] generate: ...