Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [piecewise]

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

0
votes
0answers
50 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
33 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
28 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
54 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
130 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
48 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
128 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
47 views

Piecewise function inside Integrate - Wrong result

I tried to evaluate the following integral: ...
2
votes
1answer
60 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
64 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
28 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
53 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]: ...
3
votes
4answers
206 views

Continuous non-piecewise equivalent of smoothstep function?

I have a smooth step function given by the piecewise function ...
2
votes
0answers
77 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
76 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
104 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
59 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
62 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
59 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
20 views

Locating the interval on a piecewise function and integration :

I'm recently learning Mathematica to help me compute some difficult stuff, and let's say I have a piecewise-defined real valued function with a finite number of subpieces. I can index the intervals ...
0
votes
0answers
46 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
60 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. ...
2
votes
1answer
37 views

How to read information from a piecewise function?

I defined a periodic piece wise function y[x_] with some discrete steps with Piecewise command and two lists ...
6
votes
2answers
405 views

Solving Stefan's solidification problem - for the case of 3 regions

This question heavily related to this question, where the case of two PDE's are solved along with a zipping condition that is a function of time. Using the link in the code I have solved this set of ...
2
votes
3answers
453 views

Solve piecewise function

I have two piecewise function ...
2
votes
2answers
61 views

Combine `EvenQ` and `Clip` to create a series of pulses

I have a function that produces a single impulse spanning the range [-1,1]: func1 = Cos[Pi*(Clip[x]/2)]^2 I want to create a ...
0
votes
0answers
46 views

Using table and piecewise function together

I am trying to define an equation set, in which the function is very similar to a square wave, but instead, it is defined piecewise at each interval. Now I need to evaluate the equation at each ...
0
votes
0answers
55 views

Unable to Integrate (or NIntegrate) with Piecewise limits

Essentially, I am trying to find the following, either algebraically or numerically, where Z is defined by the piecewise function in the Mathematica code (below): $\displaystyle{\int_0^{\infty } \...
1
vote
1answer
49 views

Strange behaviour in derivative of Floor function

The function Floor[x] is piecewise constant, hence its derivatives should be piecewise zero. This is far from true in Mathematica In[497]:= $Version Out[497]= "10.1.0 for Microsoft Windows (64-...
1
vote
1answer
52 views

Help For Solving Complicated Function

I have a piece-wise defined function: ...
6
votes
2answers
159 views

Switched linear systems

I'm curious whether it is possible to solve switched linear systems within the framework of NDSolve. For example a system of linear ode's like $$x'(t) = \left\{\...
1
vote
1answer
98 views
1
vote
1answer
49 views

Mapping over a piecewise function

This is a followup to a question I posted earlier today. Suppose you have a piecewise function such as "snap=max[x,0]= x if x>0, 0 otherwise". Then you would think that it must be straightworward to ...
2
votes
3answers
101 views

Identifying maximal element in a list with case distinctions

I need to create code that identifies the positions of all maximum elements of a list. I already know that if myList contains only numbers, I can do ...
0
votes
3answers
201 views

Problem with Piecewise function

I have a Piecewise function that must be non-negative. I want to replace negative part of this function with zero. my function has two summit and two valley. I want to remove this valley because in my ...
0
votes
0answers
18 views

Using piecewise function that has multiple interpolating functions in manipulate

I have 2 solution from NDSolve that i want to animate using one Manipulate that has two option for ...
0
votes
2answers
156 views

Creating a probability distribution using Piecewise [closed]

The following "Manipulate" shows the behaviour of functions that I hope, if collected according to the rules shown further down, can be transformed into a probability distribution: ...
0
votes
0answers
69 views

Fourier coefficients of piecewise function

Let $f$ be a $2\pi$ periodic function given by $$f(x)=\begin{cases} -x&x\in[-\pi,0[\\ x&x\in[0,\pi[ \end{cases} $$ Then I can compute the ...
1
vote
1answer
70 views
1
vote
1answer
84 views

3D indicator function of a box with balls

I want to define the indicator function of finite number of identical balls with given centers and diameter in a box in Wolfram Mathematica. The box has the dimensions $0 \leq x_1 \leq l$, $0 \leq x_2 ...
1
vote
1answer
52 views

Diagonal Matrix of a Piecewise Function

I have a piecewise function now I want to do a Matrix operation on it. How can I do that? For example, the Function is like below: ...
3
votes
4answers
76 views

Splitting Piecewise with vectors to components

I have a piecewise function defined with vectors, e.g. ab = Piecewise[{ {{a1, a2, a3}, 0 < r < 1}, {{b1, b2, b3}, 1 < r < 2} }, {c1, c2, c3}] The ...
2
votes
3answers
67 views

Listwise evaluation of piecewise functions

I want to create a list of values from a piecewise function evaluated at points in a list. Is there a way to do this without using loops? For example ...
0
votes
1answer
71 views

Increasing readability of piecewise interpolate function

This is a follow-up question to Ploting a Piecewise function obtained from linear interpolation of points, where I asked how to construct a piecewise function from a list of points. I now have two ...
0
votes
1answer
116 views

Evaluating A Piecewise Function at a Point

Consider the following piece-wise function. ...
1
vote
0answers
77 views

Adding a comment inside Piecewise affects box parsing

Adding a comment in Piecewise affects how underlying box structure is being parsed (see the screenshot). I use Mathematica 11.3 on Linux.
1
vote
1answer
118 views

This PDE freezes Mathematica

I have a problem when I try to solve this PDE: ...
1
vote
2answers
108 views

Problem with the integration of this piecewise function

I encounter a problem when I try to integrate the piecewise function defined in the following code: ...
0
votes
0answers
81 views

Piecewise answer (solution) from DSolve

Please forgive me for providing only a small piece of code. I solved the 1-D particle-in-a-box quantum mechanics problem. The code is like this. ...
1
vote
0answers
59 views

Problem with the integral in the limit of a piecewise function

I have this piecewise function \begin{equation} \psi(x)=\begin{cases} \frac{1}{2} \left[ \left(ln\frac{x}{2}\right)^{2}-\left(Arctanh\sqrt{1-x^{2}} \right)^{2} \right] ,& x\le 1. \\ %1,&\text{...