Questions tagged [piecewise]

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

48 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8
votes
0answers
122 views

Syntax error in debug mode

Bug introduced in 8.0 and persisting through 10.3.0 It appears that in debug mode, the \[Piecewise] symbol and its associated grid give a syntax error. For a ...
5
votes
0answers
88 views

External and internal Assumptions on `PiecewiseExpand` and `Mod`

After this question I'm intrigued about the different behaviors depending where and how the assumptions are given. ...
5
votes
0answers
439 views

Inverse of piecewise function with pieces invertible on specific domain

I have piecewise continuous function defined below: f=Piecewise[{ {15 + 1/6*(# - 3), # <= 27}, {# - 12 + 4 * Exp[-5/24*(#-27)], 27 < #} }]; This ...
4
votes
1answer
58 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 ...
3
votes
0answers
110 views

Simplifying Redundant Piecewise Cases

I would like to perform a summation from $1$ to $M$ of a simple piecewise function. For example, ...
3
votes
0answers
106 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: ...
3
votes
0answers
107 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 ...
3
votes
0answers
105 views

Data paste in piecewise table

How can I paste data copied from several lines into a piecewise table, without pasting it in a single cell?
2
votes
0answers
51 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 \...
2
votes
0answers
88 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 ...
2
votes
0answers
103 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 ...
2
votes
0answers
81 views

Piecewise function Syntax error only in debug mode

If I enter the following through mathematica (11.0) through UI $$\begin{cases} 1 &x \geq 0 \\ 0 &True \end{cases}$$ No error is reported. $$\begin{cases} 1 &x \geq 0 \\ 0 &True \end{...
2
votes
0answers
286 views

Efficiently summing sets of piecewise linear functions

I am doing a type of permutation test on a collection of continuous piecewise linear functions, which I'm representing in Mathematica using Piecewise. Specifically, ...
2
votes
0answers
336 views

Piecewise functions Integration with symbol

I want to integrate one piecewise functions as following, ...
2
votes
0answers
442 views

Integration of UnitStep or HeavisideTheta

I am using Mathematica 9. If I evaluate Integrate[Piecewise[{{1 - r, r > 0 && r < R}}, 0], r] then I get ...
1
vote
0answers
57 views

Piecewise function inside Integrate - Wrong result

I tried to evaluate the following integral: ...
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
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{...
1
vote
0answers
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 ...
1
vote
0answers
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....
1
vote
0answers
79 views

Obtaining a piecewise polynomial from a plotted parametric curve using splines

Okay, so I have a picture and I have obtained a curve from it using this code: ...
1
vote
0answers
78 views

Problem with NDSolve (and NDSolve) for piecewise definite system

I am using Mathematica 10.4 on Linux system and have the following issue. I have modeled a Dubins car: x, y is its position in the plan and gt, ht is its direction. u is the angular velocity. A basic ...
1
vote
0answers
78 views

Plotting the Full width at half maximum as a function of a parameter

I have this function and I want to plot the FWHM of it as a function of the parameter "a", defined between 0 and 10. It should look like the picture attached. I also put the original equation in case ...
1
vote
0answers
75 views

Avoiding loops with breakpoints of a Piecewise function

I'm new to mathematica and I'm trying to avoid loops. The setting is the following: I have consumers with preferences (their Betas). Depending on the Beta consumers will have different preferences. ...
1
vote
0answers
307 views

Defining a piecewise function where the conditions are points

I am trying to define the following function in Mathematica: $$pw=\begin{cases} x y \cos \left(\frac{1}{x^2+y^2}\right) & (x,y)\neq(0,0) \\ 0 & (x,y)=(0,0) \end{cases}$$ I want to use this ...
1
vote
0answers
79 views

Extracting function names in Manipulate to label plot

I have previously asked a question in regards to determining the labels of the dynamic graph that I have created, but by using SetAttributes and ...
1
vote
0answers
282 views

NDSolve for an (slightly) discontinuous Piecewise input

I define a Piecewise discontinuous function V[f[t]], which depends on a function f[t] I want to get numerically using ...
1
vote
0answers
304 views

How to use interpolating functions in NSolve with a piecewise function?

I have a system of two non-linear differential equations that are piecewise, the solutions of which I would like to use to obtain the values of a third variable that is also piecewise. I have trouble ...
1
vote
0answers
81 views

NDSolve with (approximately continuous) Piecewise input

I am finding some troubles when using NDSolve with this piece of code: ...
1
vote
0answers
239 views

Piecewise in 2D with quadrants as conditions

I am trying to define a piecewise vector field. Can the condition be of the form I am using (i.e. a quadrant)? I can't also make Piecewise work with more than two ...
1
vote
0answers
392 views

Maximize and NMaximize don't work for my function

I defined the following function: d1[x_] := Min[Abs[FractionalPart[x]], 1 - Abs[FractionalPart[x]]] and tried to evaluate the following function: Maximize[{Min[d1[15*x],d1[12*x],d1[18*x]],Abs[x-...
0
votes
0answers
63 views

Fit a three-pulse sequence

I am wondering how to properly fit the three-pulse sequence shown below. I have tried a method which is fitting the three pulses with three polynominal functions seperately and then finding the x-...
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 ...
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 ...
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
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 ...
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: ...
0
votes
0answers
85 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
101 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. ...
0
votes
0answers
155 views

Integral of a step function ,

I am trying to integrate a step function given in a book, but it doesn't work. ...
0
votes
0answers
129 views

Implicit function: derivative of piecewise function that has a FindRoot in one of the pieces

I have a piecewise function that has as one piece the result of a numerical approximation, like in the example below: ...
0
votes
0answers
70 views

FindRoot and piecewise

I want to solve numerically for a variable, let's say x. The equation that defines x has as argument a piecewise function that ...
0
votes
1answer
661 views

Fourier Transform plot of a piecewise function

I'm working with financial data. I used "Find Formula" to find an approximate function and then I applied FourierTransform to it. Here are the function and the Fourier Transform: ...
0
votes
0answers
103 views

Adding advection to a diffusion model

I am attempting to add advection to my mathematica model of 2-D Diffusion. I am trying to add a sine-flow vector field, which is A*sin[x] in the y direction and <...
0
votes
0answers
164 views

Minimize integral with piecewise functions

I am not an experienced user of Mathematica. I would like to find parameters $d1,d2,d3,e1,e2,e3$ which minimize such an integral (given $c11,c12,c13,c21,c22,c23,c31,c32,c33$): $\int_{0}^{1}\int_{0}^{...
0
votes
0answers
46 views

Obtain a SymmetricReduction of a bivariate (symmetric) function given in Piecewise form

I would like to re-express the following bivariate (symmetric) function (defined over the unit square) ...
0
votes
0answers
88 views

Trouble solving system of nonlinear equations with piecewise

Here is my code so far ...
0
votes
0answers
97 views

Transform NMinimze into LinearProgramming formulation

I have the following maximization problem that I currently try to solve with Minimize/NMinimize. Unfortunately, this kind of solution method takes really long for large systems of equations and ...