Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [piecewise]

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

310 questions
Filter by
Sorted by
Tagged with
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: ...
261 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 ...
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 ...
140 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 ...
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 ...
217 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, ...
140 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. <...
586 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.] ...
259 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: ...
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. ...
283 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 ...
87 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: ...
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 ...
640 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: ...
210 views

Problem with a periodic function and NDSolve

I have defined a periodic function $f(t)$ like this (Mathematica 11): ...
94 views

...
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. ...
189 views

114 views

Scale in plot and Piecewise

I wrote this code: ...
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: ...
388 views

Alternatives to piecewise

As has been mentioned before, Piecewise causes the Mathematica Kernel to fail to during a NDSolve calculation. How can I write ...
330 views

Performance of numerical integral over piecewise function

Using mathematica version 10.3, I observe that an integral over a piecewise function evaluates a factor 10 slower than the same integral without the piecewise distinction. Here is the code: ...
78 views

...
279 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 ...
1k views

Derivatives of piecewise functions of functions

Background Derivatives of piecewise functions in Mathematica are computed according to special rules. According the Piecewise documentation (see Possible Issues), ...
2k views

How can I combine two Piecewise functions?

I want to be able to combine two piecewise functions. For example, suppose Piecewise1 = f=3 for 1 <=x <=2 and Piecewise2 = f=5 for 1.5<=x<=3, I ...
351 views

Plotting a vector function composed of piecewise scalar functions

I am relatively new to Mathematica, and am having difficulty doing something that is conceptually very simple. I am trying to plot a vector field in which the vector function is composed of piecewise ...
81 views

Plot of a piecewise function misbehaving [closed]

Hi: I am trying to plot a piecewise function. What's weird is that the plot either (a) does not appear at all, or (b) depending on settings, either appears as a horizontal/vertical time. I must be ...
287 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 ...
77 views

NDSolve with (approximately continuous) Piecewise input

I am finding some troubles when using NDSolve with this piece of code: ...