Questions tagged [piecewise]

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

60 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8
votes
0answers
130 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 ...
6
votes
0answers
63 views

difference between right click and “copy as LaTeX” and directly using TeXForm

...
5
votes
0answers
92 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
472 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
115 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 ...
3
votes
0answers
132 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
118 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
121 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
110 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
50 views

How to get Integrate to determine units

In a similar fashion to the question asked here, I am having trouble trying to get Integrate to correctly determine the units of the integrand: Here I have plugged in specific values into the general ...
2
votes
0answers
89 views

How do I create a piecewise function using Do[] or While[]?

The following non-linear circuit is an uncontrolled three-phase full-wave 6-pulse rectifier. The inputs are $v_{an}(t) = V_m \sin (\omega t)$, $v_{bn}(t) = V_m \sin (\omega t-120°)$ and $v_{cn}(t) = ...
2
votes
0answers
55 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
119 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
95 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
342 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
382 views

Piecewise functions Integration with symbol

I want to integrate one piecewise functions as following, ...
2
votes
0answers
477 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
50 views

Manipulate and Plot of Tangent Point in Optimization Problem with Kinked Constraint: Solve and PieceWise Problems

I'm trying to illustrate an optimization problem with a piecewise constraint creating a kink at the maximum value of T if n>0. ...
1
vote
0answers
34 views

Find edges of a piecewise curve

I have a continuous function f[x], and I want to calculate the coordinates of the discontinuities in Round[f[x]]. My code needs ...
1
vote
0answers
21 views

```PiecewiseExpand``` doesn't work as expected with a recursive function

In an effort to examine this question on Math.SE, I defined the following functions ...
1
vote
0answers
62 views

Speed up Integrate around Max/Min or Piecewise

Integrate around a convex combination of two functions containing Min or Max or ...
1
vote
0answers
60 views

Piecewise function inside Integrate - Wrong result

I tried to evaluate the following integral: ...
1
vote
0answers
80 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
115 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
74 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
40 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
57 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
86 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
80 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
86 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
78 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
404 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
82 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
316 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
370 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
92 views

NDSolve with (approximately continuous) Piecewise input

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

Assumptions with piecewise problem?

I am trying to apply the assumpion of 0<s<1 throughout the calculation however the piecewise condition does not accept it automatically. Is there any way to avoid the manual choice of x>0. ...
0
votes
0answers
36 views

Piecewise function inside ProbabilityDistribution causing errors

I'm using a complicated Piecewise function to create a probability distribution and draw random points from it. ...
0
votes
0answers
33 views

Plotting a piecewise function MRI problem

I have this M.R.I. question, and i need to plot a function with some 'a' and 'b' parameters and 't' as a variable: ...
0
votes
0answers
25 views

Find and indicate the minimum of a piecewise function in the `Plot3D` diagram

I'm trying to indicate in my Plot3D diagram the minimum level of the dependent variable and the corresponding levels of two independent variables. More specifically,...
0
votes
0answers
40 views

Bad Integral evaluation for Piecewise function

I have been trying to evaluate this symbolic function: f[ρ_, R_, α_, yp0_, yp_] := R*((ρ - R*Cos[α])^2 + (R*Sin[α])^2 + (yp-yp0)^2)^(-(1/2)); Mathematica can ...
0
votes
0answers
93 views

Using NDSolve and PieceWise for boundary conditions for coupled PDEs

I've decided to try and use PieceWise in my boundary conditions for my 4 coupled PDEs, but it doesn't seem to work out nicely. I'm receiving the error: NDSolve::overdet: There are fewer dependent ...
0
votes
0answers
94 views

Fit piecewise function

I want to fit my data with the following function ...
0
votes
0answers
70 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
46 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
21 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
46 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
56 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 ...