Questions tagged [piecewise]

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

50 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8
votes
0answers
119 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
86 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
407 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 ...
3
votes
0answers
102 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
99 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
98 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
104 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
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 \...
2
votes
0answers
83 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
78 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
71 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
257 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
315 views

Piecewise functions Integration with symbol

I want to integrate one piecewise functions as following, ...
2
votes
0answers
424 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
33 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 ...
1
vote
0answers
55 views

Piecewise function inside Integrate - Wrong result

I tried to evaluate the following integral: ...
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
0answers
62 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
76 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
76 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
77 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
261 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
78 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
276 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
279 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
76 views

NDSolve with (approximately continuous) Piecewise input

I am finding some troubles when using NDSolve with this piece of code: ...
1
vote
0answers
236 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
378 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
33 views

Function inverse to PiecewiseExpand

I'm working with very complex piecewise functions which I'd like to decompose into combination of simpler ones. I'm aware of PiecewiseExpand function which does the opposite to what I need. Is there a ...
0
votes
0answers
37 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
53 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
34 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
24 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
56 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
56 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 } \...
0
votes
0answers
21 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
0answers
76 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 ...
0
votes
0answers
89 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
136 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
118 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
69 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
557 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
90 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
151 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
85 views

Trouble solving system of nonlinear equations with piecewise

Here is my code so far ...
0
votes
0answers
96 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 ...