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
0
votes
3answers
307 views

How do I insert a circle inside another circle with Piecewise?

I need to create two circles, where one circle is inside the other using the Piecewise function. So far I have ...
1
vote
2answers
85 views

Piecewise integration fail or something else?

I have a not-so-complicated piecewise cubic function, shown below as the yellow curve on the right. It's derivative is on the left; the blue lines are references. Please see the code below where I ...
3
votes
2answers
85 views

Difference in Piecewise function

I have two piecewise functions that are defined on values of [0,200]. I would like to find out the maximum difference between the two values. The usual Max[] function does not work because all values ...
1
vote
1answer
211 views

Piecewise function created from list

I have a list of values called EDFh3. This contained values which are partitioned by 3 where it is in the format ...
1
vote
1answer
213 views

How to implement a loop inside Piecewise?

I wanna be able to use the Piecewise function such that I don't have to manually enter all the pieces. For example, say I define f[x_]:={x,x^2,x^3} Consider now ...
1
vote
1answer
120 views

DSolve, Simultaneous Eqns + Piece-wise + boundary and initial conditions

mathematica noobie here but could really use some help. So I have 2 sets of equations: 1) w''''[x]=0 and 2) w''''[x]=q[x] 1) has conditions w[0]=0, w'[0]=0 2) has conditions w''[1]=0, w'''[1]=0 1) ...
3
votes
2answers
264 views

Plot of piecewise function is not bounded properly

I am trying to plot a piecewise function that gets bounded above and below a certain value (e.g). ...
0
votes
1answer
93 views

Selecting only list of function output from piecewise function output [closed]

Say I have a piecewise function: V[m_] := Piecewise[{{(1 + m)^2, m >= 1}, {Log[m], m < 1}}] And I input a large list of ...
0
votes
1answer
2k views

Plotting a piecewise function [closed]

I'm having trouble plotting the piecewise function below. The only way I can replicate this function is using ...
1
vote
1answer
205 views

Variable Increments in a Table

I am working on a problem involving the piecewise function: $$x^2 \quad \mbox{if } \quad x < 2$$ $$(x-3)/(\sqrt{x-2}-1) \quad \mbox{if } \quad x \geq 2$$ I am supposed to find ...
0
votes
3answers
129 views

How I can define this staircase function?

I have a function $f:[-1,1]\to\Bbb R$ defined by $$f(x):=\begin{cases}\frac1{n+2},&x\in\left[-\frac1n,-\frac1{n+1}\right)\cup\left(\frac1{n+1},\frac1n\right]\\0,&\text{otherwise}\end{cases}\...
1
vote
3answers
67 views

Can i use PiecewiseExpand to expand If statements with function arguments?

Usually PiecewiseExpand[] is able to convert If[] statements to Piecewise functions, e.g. <...
1
vote
1answer
119 views

Interpretation of HeavisideTheta Integration Output

I need to integrate integrals of the type Integrate[Boole[2 k*q >= Absolute[p^2 - k^2 - q^2]], q] where $q$, $k$, and $p$ go from $0$ to $1$. To learn to ...
1
vote
1answer
224 views

How to write a piecewise function to take a list of {value,point} as its parameter?

I want to apply Piecewise function to a list of range and values, for example, to make f[{{v1,r2},{v2,r2},{v3,r3},{v4,r4},...,{vn,\[Infinity]}}] generate: ...
2
votes
2answers
86 views

Derivation of this piecewise function introduces “numerical noise”

The following function is a piecewise function. It's easy to plot with option Exclusions->None but it's derivative is hard to evaluate: ...
0
votes
0answers
153 views

Piecewise defining function, Why do i get extra 0 True? [duplicate]

I have included a picture This happens on every Piecewise function
0
votes
0answers
154 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}^{...
8
votes
1answer
144 views

Bug in PiecewiseExpand and Mod with assumptions

Bug introduced in 9.0 or earlier and fixed in 10.4 The following code using PiecewiseExpandand Modgives the wrong answer <...
4
votes
2answers
355 views

Compile error from If but not from Piecewise

Consider this: point={1.,2.}; f1 = Compile[{{t, _Real}}, Evaluate[Block[{a, b}, {a, b} = point; If[t > 0., a*b*Sin[t], 0.]]]]; f1[2.] CompiledFunction::...
10
votes
3answers
2k views

Can NDSolve handle discontinuous data?

Backslide introduced in 9.0, persisting through 11.0.1 It is possible to numerically solve a differential equation if not-smooth data are involved? For example the following instruction return the ...
4
votes
3answers
180 views

Getting error message when integrating a simple piecewise function

I reviewed the following questions: question 1 and question 2, but I need to the following integral of a piecewise function: ...
1
vote
1answer
177 views

Using Manipulate to Plot a Piecewise Function

I want to plot a piecewise function with two variables using Manipulate command, but I am having trouble with it. The function I want to plot is profit1. (details of the code can be found below) <...
1
vote
2answers
243 views

Calculating probability of piecewise function

I want to calculate the probability of a discrete random variable. First I defined the function: pw = Piecewise[{{1/8, x == 1}, {2/8, x == 2}, {5/8, x == 3}}, 0]; ...
3
votes
2answers
409 views

InterpolatingFunction within Piecewise gives range error?

So I have a function myfun with positive domain that I got from NDSolve and a bunch of transformations afterwards. I can plot it on its own like ...
4
votes
2answers
592 views

How I can make the StreamPlot of this differential equation?

I need the StreamPlot of this differential equation but I don't know how. dp/dt = 0.4 p(1 - p/30), 0 <= t < 5 and 0.4 p (1 - p/30) - 0.25 p, t > 5
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) ...
1
vote
1answer
102 views

Create piecewise f[x,y] from functions with intersecting domains

I have two functions f1 and f2. They have a square region in the $x-y$ plane as their domain. They might intersect, or they ...
2
votes
3answers
632 views

Complicated condition inside piecewise function

I want to define the piecewise function $$f(x)=\begin{cases}-1,&x\ge1\\\frac1n,&\frac1{n+1}\le x<\frac1n,\; n\in\Bbb N_{>0}\\0,&x\le 0\end{cases}$$ in this form, but I don't know ...
0
votes
1answer
89 views

how to plot a solution of differential equation, which is a piecewise function?

I want to plot the solution of a differential equation, which involves a piecewise function, the rectangle function UnitBox. As a result, the solution computed by ...
2
votes
1answer
88 views

Apply a list of functions to an argument inside Piecewise

I would like use Through, or some other method, to apply a list of functions to the same argument inside Piecewise. For example, ...
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 ...
3
votes
2answers
105 views

Visualization of nested Piecewise output with a tree diagram (or something similar)

I have outputs which are in the form of nested Piecewise functions and I want to represent these diagrammatically. There are multiple levels in general. A simple example with two levels is: ...
4
votes
1answer
136 views

Piecewise[] merge equivalent conditions

Is there a simple way to merge equivalent conditions in Piecewise? For example, in the following we have (trivially) pw==x. <...
4
votes
1answer
271 views

Conversion between Piecewise[] and Abs[] representations [duplicate]

Is there a utility in Mathematica that can convert between two representations of an expression? The simplest example I can think of is Abs[x] Which I'd like to ...
1
vote
0answers
76 views
3
votes
1answer
252 views

Extraneous cases in simplified piecewise function

I'm trying to get Mathematica to simplify a piecewise function, but as you can see below it's making some strange errors: I'm telling it i and g are integers, so it ought to know that 2g>4+i is ...
2
votes
1answer
134 views

Piecewise get value at x [closed]

I have a piecewise function like this. fP = Piecewise[{{x^2, x < 0}, {x, x > 0}}]; Plot[fFu, {x, -2, 2}] Now I want to get the y value at a certain x ...
4
votes
1answer
583 views

Can one compile the Switch function?

I am aware that one can compile Which, e.g.: ff = Compile[x, Which @@ {x < 0, 2, x >= 0, 3} ff[1.] ...
4
votes
2answers
120 views

Are there any code which just derivative of piecewise function(same distence)?

I wrote this code: Piecewise[{{x^2, 0 <= x <= 1}, {x, x <= 4}}] and I got its derivative with this code: ...
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 ...
2
votes
1answer
240 views

Piecewise function extraction

I have a piecewise function and I'm trying to extract the different functions for different values of the parameter. I use: ...
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
269 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 ...
5
votes
2answers
618 views

Defining a piecewise function from a sequence of functions [closed]

I'm attempting to define a piecewise function from a sequence of defined functions. I've attempted something like this: ...
3
votes
2answers
207 views

Problem with a periodic function and NDSolve

I have defined a periodic function $f(t)$ like this (Mathematica 11): ...
1
vote
2answers
93 views
0
votes
1answer
116 views

Mapping a simple 2 variable function

Quick Question: What is the best way to map this function so it performs seperately for 102 different values of x? ...
1
vote
1answer
71 views

symbolic function assignment yields different results than explicit assignment

I am confused as to why the two functions below yield different results (as vs ss)? One function assigns the Piecewise function directly, while the other reads the same function from a list of lists. ...
3
votes
1answer
184 views

Edit piecewise function

Downstream of a long process I got the following function: $\begin{cases} 0 & x < 0 \, \vee \, x > \frac{307}{400} \\ 14.27-7.44\,x & 0 < x < \frac{307}{400} \\ \text{...