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
3
votes
2answers
296 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
118 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
3k 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 ...
0
votes
3answers
395 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
1answer
313 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
155 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
74 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
155 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
276 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: ...
0
votes
0answers
263 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
175 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}^{...
4
votes
3answers
191 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
226 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
351 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
501 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 ...
11
votes
2answers
535 views

StreamPlot No Longer Works With Piecewise Function?

Bug introduced in 7.0.1 or earlier and persisting through 11.1 I was trying to plot a phase portrait (StreamPlot) using a piecewise (...
1
vote
1answer
131 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
979 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
100 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
92 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, ...
3
votes
2answers
112 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
330 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
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: ...
3
votes
1answer
341 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 ...
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 ...
2
votes
1answer
194 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 ...
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 ...
10
votes
2answers
223 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, ...
4
votes
1answer
180 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. <...
5
votes
1answer
634 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.] ...
3
votes
1answer
382 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
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 ...
2
votes
2answers
94 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: ...
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 ...
5
votes
2answers
745 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
245 views

Problem with a periodic function and NDSolve

I have defined a periodic function $f(t)$ like this (Mathematica 11): ...
1
vote
2answers
214 views
1
vote
1answer
72 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
247 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{...
0
votes
1answer
115 views

Strange behavior of derivative when using Abs[] [duplicate]

This code where I try to visualize Newton's Method on the function $f(x)=\sqrt{|x|}$ works fine when I define $f(x)$ piecewise. Then why doesn't it work when I define ...
0
votes
1answer
538 views

How to apply a piecewise function to a list? [closed]

I have created this code: xn = {4, -4, 4, -4} f[x_] = Piecewise[{{Sqrt[x], x >= 0}, {Sqrt[-x], x < 0}}] f[xn] With this code I would expect as a result: ...
2
votes
2answers
167 views

Integrate over a piecewise function [closed]

I want to calculate the indefinite Integral of $$f(x)=\begin{cases} 2x\cos(\frac{1}{x})& \text{ if } x\ne 0 \\ 0& \text{ if } x=0 \end{cases}.$$ I use the following code: ...
0
votes
1answer
120 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? ...
2
votes
2answers
730 views

solve system including piecewise function

I've read posts about how to do this in a direct way, but the method doesn't work for my simple system? -- see code: ...
0
votes
1answer
99 views

When does this function equal 'true'? [closed]

I've used Mathematica to find the function $f(t)$ and I found this: Q: What does 'true' say about the function. Is it always equal to $ae^{-\frac{t}{p}}$ or what does it mean?
4
votes
1answer
283 views
2
votes
2answers
363 views

How do I solve Schrödinger equation with a piecewise periodic Hamiltonian? [duplicate]

My Hamiltonian is HI(t) = Piecewise[ {{H1, n τ <= t <= (n + 1/2) τ}, {H2, (n + 1/2) τ <= t <= (n + 1) τ}}] where ...
1
vote
4answers
474 views

Implicitly inverting a function from numerical solution [closed]

I have the following piecewise continuous function: ...
3
votes
2answers
491 views

Switching Differential Equation in NDSolve

I am trying to solve the following system of differential equations using NDSolve: $\dot{z}_t=.5(1-z_t)$ $\dot{y}_t=.05y_t+z_t-x_t$ subject to the following constraint: $-y_t-z_t\le0$ where $z_t$ ...

1
4
5
6 7 8