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
70 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
349 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: ...
7
votes
2answers
491 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 ...
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
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. ...
2
votes
1answer
40 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 ...
2
votes
3answers
571 views

Solve piecewise function

I have two piecewise function ...
2
votes
2answers
69 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
81 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 ...
1
vote
1answer
109 views
0
votes
3answers
311 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 ...
1
vote
1answer
54 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-...
6
votes
2answers
162 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
54 views

Help For Solving Complicated Function

I have a piece-wise defined function: ...
1
vote
1answer
53 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
109 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 ...
2
votes
2answers
529 views

Piecewise ColorFunction for Plot3D

I want to make a 3D plot where the ColorFunction is different depending on whether the function value is positive or negative. I know how to do the following: ...
0
votes
2answers
214 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: ...
1
vote
1answer
98 views
1
vote
1answer
92 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
74 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
80 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
77 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
78 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 ...
10
votes
2answers
219 views

Problem with Integrate with Piecewise and PrincipalValue

Bug introduced in 8.0.4 or earlier and persisting through 11.3 In the course of developing an alternative solution for question 127301, With, ...
0
votes
1answer
163 views

Evaluating A Piecewise Function at a Point

Consider the following piece-wise function. ...
1
vote
0answers
78 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
128 views

This PDE freezes Mathematica

I have a problem when I try to solve this PDE: ...
1
vote
2answers
141 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
100 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
69 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{...
0
votes
1answer
99 views

Defining a function to be the minimum of two other functions

I cannot find a way to define a function as the minimum of two other functions that each have the same two independent variables. I have f(x,y) and g(x,y), and I would like to find $h = \min\{f(x,y),g(...
1
vote
1answer
68 views

Dynamic GUI problem

I'm fairly new to Mathematica and currently making a simple GUI. I'd like to work with dropdown menus and I'd like to dynamically change the possibilites of those menus depending on what's selected ...
0
votes
1answer
368 views

Finding the tangent to a piecewise function

I'm new to Mathematica and I am trying to calculate the expression of the tangent to the curve ...
2
votes
1answer
148 views

Symbolically Minimizing Expression with Multiple Piecewise Functions

Following up my previous question about ArgMin, I now face a situation where the solution to an ArgMin call, where the output is ...
0
votes
1answer
233 views

Differential equation with piecewise coefficient

I have this equation and I need to solve it analytically by Mathematica https://i.stack.imgur.com/fCnxk.png I tried the following ...
2
votes
0answers
101 views

Understanding ArgMin with constraints

Consider this simple snippet: ArgMin[{(x - a)^2, -1 <= x <= 1}, x] which should (in my mind) output something like $$ x = \begin{cases} -1 & a < -1 ...
0
votes
1answer
2k views

Plot a piecewise function of two variables [closed]

How can I plot with Mathematica, Muller's example: $f(t,x) = \begin{cases} 0 & t \leq 0, x \in \mathbb{R} \\ 2t & t>0,x < 0 \\ 2t - \frac{4x}{t} & t >0,0 \leq x \leq t^2 \\...
2
votes
2answers
345 views

Vertical Lines at steps of HeavsideTheta

I want to plot the following: Plot[{Sqrt[x], Sum[HeavisideTheta[x - n^2], {n, 1, Floor[x]}]}, {x, 0,50}] which looks like Is there a simple way to get this same ...
0
votes
2answers
156 views

Plotting a piecewise function in Mathematica 10.0

How to I plot the following function in one diagram: from $0$ to $\frac{\pi}{2}$ the function has to equal $\left|\sin\left(x\right)\right|$ and from $\frac{\pi}{2}$ the function $\exp\left(-\frac{x}{...
10
votes
5answers
1k views

NIntegrate extremely piecewised functions

I often need to integrate extremely piecewised functions, like the following one (not extreme, but gives an idea): ...
8
votes
2answers
535 views

Using OddQ and EvenQ in piecewise functions: Buggy?

I was trying to evaluate a sum over a piecewise function, not unlike this example. However, my piecewise function needed to be defined differently for even and odd ...
2
votes
2answers
139 views

ElementwiseLayer with Piecewise?

I need a specific custom activation function; how can I implement it with Piecewise? This is what I've tried (using the recommendation from this question): ...
-1
votes
1answer
234 views

Find roots for piecewise function

I'm trying to find the root of the function below (fun[t2_]). FindRoot can't find it due to nlnum error, i.e. the function's output is not a number but a Condition or Plus. How do I manage to it work?...
3
votes
2answers
119 views

Very slow code for simulation of optical emission (Raman) spectra

Can anyone help me optimise my code? It currently takes up to 2 hours to run a calculation! I have written a simple code to simulate a type of optical emission spectrum (Raman scattering) for ...