Questions tagged [piecewise]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
33 views

Interpolation of a “bit by bit” Function

I am facing a problem with integrating a function. I have to integrate the function "bit by bit". This is the smallest working example that shows the problem: ...
0
votes
1answer
54 views

Integrating a function “bit by bit”

I am trying to integrate a function. But for this task I need to do it "bit by bit". I created a working example that shows the problem. ...
1
vote
2answers
47 views

How to choose model parameters using `Piecewise` function

The following code (developed by m_goldberg) works as expected. The model parameters can be selected by using Button, being ...
3
votes
2answers
128 views

Different colours for different sectors of piecewise function

I have some lines of code that generate numerical solutions to equations. Then I want to combine two of these in a piecewise function. The way I did it is the following -lf1[r] and lf4[r] are the ...
6
votes
2answers
140 views

How can I use Callout to label the segments of a piecewise function?

When I plot a Piecewise function, I like to put the function name above each part of the plot. I could not find a way to use ...
1
vote
1answer
83 views

Piecewise function made up of five segments not showing in a plot [closed]

I want to plot 5 parts in a single graph using a piecewise function. But I am not able to plot the last one. Can anyone please help me with it? The code is as follows. ...
0
votes
1answer
112 views

How to solve transient 3D heat equation with robin boundary conditions

Good afternoon! I'm trying to solve the following heat equation: with the following boundary conditions and initial value: Nut I'm getting error while solving it with NDSolve: ...
3
votes
3answers
58 views

Dots at points of discontinuity

So, I got this code: Plot[Piecewise[{{3, x <= 0}, {x^2 + 1, x > 0}}], {x, -2, 2}, PlotStyle -> {Purple}, Axes -> False, Frame -> True] and I ...
3
votes
1answer
79 views

Reduce to Piecewise

There are some similar posts on SE, but none of them seems to exactly address my issue. I need to integrate a rather complicated function (over $x>1$) separately over two domains defined as ...
0
votes
0answers
42 views

Plotting discontinuous functions

I want to plot the two roots of a polynomial function. At some value of the variable x, they "swap" and the lines change. However, I want each branch to have te same line style. Is it possible to ...
3
votes
1answer
107 views

How to set up a Fourier transform?

I am having trouble figuring out how to set up the Fourier transform to: ...
6
votes
2answers
158 views

The correct way of compute indicator function in Mathematica

$$X_1= \mathbb{1}_{[0,1]} $$ $$X_2= \mathbb{1}_{[0,\frac{1}{2}]}, X_3= \mathbb{1}_{[\frac{1}{2},1]}, $$ $$X_4= \mathbb{1}_{[0,\frac{1}{3}]}, X_5= \mathbb{1}_{[\frac{1}{3},\frac{2}{3}]}, X_6= \mathbb{...
1
vote
1answer
41 views

Having trouble when using a piecewise function

I am trying to define a function where H1[x_]= a previously derived value if 0 < x <100 and H1[x_]=x if x>100 so I have used the following piecewise function: H1[x_]:=Piecewise[{{Evaluate[y[x] /....
0
votes
0answers
20 views

Problem with PiecewiseExpand[Max[ ]]

I have these functions: By running this command: FullSimplify[PiecewiseExpand[Max[a, b , c, x, y, z]], 9 <= \[Beta] <= 11] I obtain: However I think ...
2
votes
1answer
53 views

Maximization of a a PiecewiseExpand funcion

I have the following 3 piecewise functions and their upper envelope. ...
1
vote
1answer
48 views

Find the intervals where a piecewise is maximum

I have the following 3 piecewise functions and I would like to have the threshold of the upper envelope. ...
7
votes
1answer
109 views

Converting Piecewise function to C code

I'm trying to convert a function to C Code f = D[Piecewise[{{x^2, -10 < x < 0}, {x, x > 0}}], x] I decided to scan through conditions and corresponding ...
0
votes
1answer
72 views

Extending periodic piecewise continuous function

I need to plot the piecewise function $$ f(x) = \left\{ \begin{array}{r} x^2, & -2 \leq x \leq 0, \\ 0, & 0 < x \leq 1, \\ 1 - x, & 1 < x \leq 3. \\ \end{array} \right. $$ as a ...
2
votes
0answers
36 views

How to convert output from Reduce into a piecewise function?

Reduce often provides a much fuller solution than Solve. But it's always in the form of a true statement rather than functions ...
2
votes
2answers
70 views

How to define a discrete distribution with non-integer sample space elements (outcomes)?

How to define a discrete distribution with non-integer states (sample space elements)? I know how to define a discrete distribution with integer states: ...
0
votes
1answer
53 views

Piecewise function [closed]

I have the differential equation $$ \omega'(t)= \begin{cases} \frac{1}{J_t}\left(\frac{B}{2}(F_l-F_r)-B_l\omega\right) & \text{if turning=true}\\ 0 & \text{if ...
3
votes
1answer
66 views

elegant definition of piecewise linear functions (spline)

As far as I understand, the Spline object is the result of some approximation or interpolation, it is not for directly defining functions. That's a pity, as that ...
1
vote
1answer
77 views

Piecewise with differential equations

I have the following differential system. The calibration I use is as follows ...
3
votes
1answer
68 views

Piecewise function not evaluating in NDSolve

Perhaps it's something obvious, but why does this simple piecewise function (as well as other conditionals) not evaluate in NDSolve: ...
0
votes
0answers
42 views

Piecewise function to include SawtoothWave function

I am trying to write a Piecewise function that includes the SawtoothWave function. Can someone indicate how to do this, or if it is possible within mathematica? The piecewise code is here: ...
0
votes
1answer
35 views

How does Mathematica solve this 2D piecewise function from constraints?

I am interested in learning the technique(s) used to solve the following 2D piecewise equation for $x, y$ when given $z$, where $z = f(x, y)$. $\text{Given that $x \in \mathbb{Z}$, $y \in \mathbb{Z}$}...
2
votes
2answers
40 views

Piecewise function and deriving - solving

I'm working in a (Economics) problem where I want to add two concave (profit) functions in order to maximize them together through one variable (quantity). My problem is that one of the two functions ...
4
votes
2answers
268 views

Why does plot not show where Piecewise function is not zero?

From my user point view this looks like bug. But I am not an expert. f[x_?NumericQ]:=Piecewise[{{1,x==1},{0,True}}]; Plot[f[x],{x,0,1}] Does not show ...
1
vote
2answers
49 views

Displaying part of piecewise function

If I define a piecewise function f[t_] := Piecewise[{{t^2, t < 0}, {Sin[t], t > 0}}] Which[f[t], t > 0] how do I display only one part of the function? ...
0
votes
0answers
55 views

Is it possible to unmerge Piecewise expressions?

I have an expression involving Piecewise that I want to break into specific cases. If I let Mathematica's simplification rules loose then it doesn't seem to pick up an obvious cancellation which can ...
1
vote
2answers
41 views

RecurrenceTable of a piecewise recurrence function

How to can I get RecurrenceTable to deal with a piecewise function? For example, $ \qquad x_{n+1}= x_n(1.5-0.5x_n)\qquad \text{if $x_n\ge0.5$}\\ \qquad x_{n+1}= ...
0
votes
2answers
32 views

Piecewise vector

I need to have a vector with the length of 15000. The first 4000 elements have value 12, the next 3000 elements, that is 4001 to 7000 be 0 and the rest of it to the last be 5. I have written it with ...
0
votes
1answer
58 views

Returning a string from a piecewise function

I need to define a function that behaves as a piecewise function, but will return a string instead of a value. Part of the function that I have written is provided below. The full function continues ...
4
votes
2answers
205 views

Heat equation with variable conductivity

Let us consider the (very simple) problem $\qquad \partial_x[k(x)\,\partial_xu]=0,\quad x\in [0,1]$ $\qquad u(0)=0,\ u(1)=1,$ with $l\in(0,1)$ $\qquad k(x)=\left\{\begin{array}{l}k_1^{},x<l\\k_2^...
2
votes
0answers
50 views

Make Mathematica evaluate an integral symbolically

The following integral has a symbolic solution, which MMA does not return. $\kappa(x) \begin{cases} \text{mod}(x,1)\le0.5: & 1\\ \text{mod}(x,1)>0.5: & 0 \end{cases}$ $f(z)=\int_0^1 \...
0
votes
2answers
294 views

Fourier series of an arbitrary periodic piecewise function

Let's take a switch function as an example: $ u(t)= \begin{cases} 1, & \text{$0<t<dT_s$} \\ 0, & \text{$dT_s<t<T_s$} \end{cases} $ How can I get Fourier series of it in ...
1
vote
0answers
57 views

Piecewise function inside Integrate - Wrong result

I tried to evaluate the following integral: ...
2
votes
1answer
94 views

Fast and Listable Piecewise function

I am writing a simulation where I have an array with ten columns and on the order of millions of rows, for which I need to iterate on the order of ten thousand times, making computation time a major ...
4
votes
2answers
68 views

How can I make a NumberLineLogPlot'?

I have a piecewise function that is defined in logarithmic intervals, i.e., the different pieces are defined on ...
0
votes
0answers
45 views

Imposing conditions on argument for a function definition

Suppose that I wish to use "Piecewise" to merge two different interpolating functions (obtained via a NDSolve of some ODE), defined over negative and positive arguments respectively, like: ...
1
vote
1answer
69 views

Integrating piecewise function in two variables

I want to find (and plot) the integral of a 'smooth' version of the Möbius function MoebiusMu[x]: ...
4
votes
4answers
347 views

Continuous non-piecewise equivalent of smoothstep function?

I have a smooth step function given by the piecewise function ...
2
votes
0answers
87 views

Slow Plotting of a Piecewise Function

I have stumbled upon an issue that seems very weird to me. I have two Piecewise functions that describe exactly the same curve. The only difference between them is that the first function has two ...
0
votes
1answer
90 views

Convert a piecewise definition of a single impulse into an impulse train

NOTE: See update at end of question I have a function smoothstep (based on the derivative of a smoothstep function) that gives a single impulse as follows: ...
0
votes
1answer
183 views

How to change colors of 3D parametric plot

I have a 3D iterative plot, where each iteration (1,2,3) is represented by equation of piecewise linear function. I am trying to change the colors of plot, to get for every iteration (piecewise ...
0
votes
1answer
60 views

Defining a function with a point of finite discontinuity [closed]

I wrote the code for the function $T$ defined on $[0,1]$ by $T(x)=\frac{x+2}{3}$ if $x\neq\frac{1}{2}$ and $T(\frac{1}{2})=1$ as follows. ...
0
votes
2answers
95 views

How to plot 3D discontinuous iterative plot?

I am having troubles with plotting this set of data triples={{0, 1, 1}, {9/50, 4/5, 1}}, {{9/50, 4/5, 1}, {3/8, 4/5, 1}}, {{3/8, 58333/100000, 1}, {3/4, 16667/100000, 1}}, {{3/4, 0, 1}, {1, 0, ...
0
votes
2answers
82 views

how to get coordinates from a plot of piecewise function?

I am having troubles with finding points from a plot. I have a piecewise linear function given by following inequalities. These inequalities I got from previous calculations where I split two ...
0
votes
0answers
50 views

How to extract envelope for piecewise defined function? [duplicate]

I have a plot generated from an ugly and complex set of piece-wise functions. I'm looking to extract the envelope function from this data set. I've tried a lot of suggestions in other threads, but ...
0
votes
1answer
63 views

Using Piecewise to plot a defined function [closed]

I'm trying to Plot this function: Between the interval -0.2 < t < 0.1 but it doesn't work. All i get is a blank graph between my intervals. If you could help me out I'd greatly appreciate it. ...