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
1
vote
1answer
43 views

NDSolve with embedded piecewise function for state-variable

Given ODE: $\dot{x}=-2 e^{-x^2} x + U$ where: $U=-u_{as}$ $u_{as} = \begin{cases} \frac{e}{\psi_+-e}, & \mbox{if } e\mbox{>=0} \\ \frac{e}{e-\psi_-}, & \mbox{if } e\mbox{<0} \end{cases}$ ...
0
votes
0answers
25 views

Piecewise function evaluation not working [closed]

I want to construct a piecewise function that consists of 3 segments. I first define them as n1, n2, n3: ...
0
votes
0answers
35 views

How to left-align rows? [closed]

I want to left-align rows, but I cannot figure out how. What I am doing to create the rows is press ctrl+enter, but when I enter expressions of different sizes in the rows, then they centre instead of ...
0
votes
5answers
81 views

Expressing $f(x)=-x \;\;\; -2\leq x \leq 0\\f(x)=x \;\;\; 0< x \leq 2\\f(x+4)=f(x)$ on Mathematica?

Can we express functions such as: $$f(x)=-x \quad -2\leq x \leq 0\\f(x)=x \quad 0< x \leq 2\\f(x+4)=f(x)$$ On Mathematica? I tried something with piecewise functions but it didn't work. Namely, I ...
1
vote
1answer
51 views

Different kind of PlotStyle via Piecewise

I have a Piecewise. For vertical line I have to add Exclusions -> None. ...
0
votes
2answers
81 views

Piecewise function within a vectorplot

I'm trying to do a vector plot with some code that includes piecewise functions and I keep getting the following error: Part::partw: Part 1 of {} does not exist. Here is the code: ...
0
votes
1answer
81 views

Piecewise Numerical results used in NDsolve

I have a solution of LinearSolve. And there are four conditions in single period. Then I used Which to expand this solution. <...
1
vote
0answers
46 views

Generate piecewise function using for loop

I want to specify a piecewise function by writing f[x_]:=Piecewise[piecewiseComponents], and use a loop to specify the components. I have tried ...
3
votes
1answer
61 views

Creating a dynamic piecewise plot

I'm trying to create a dynamic piecewise function. I can get 3 points, but after that, everything gets a bit complicated: ...
0
votes
0answers
28 views

Simplifying piecewise function containing symmetric equation terms

I have this large piecewise function that I'd like to simplify (click on image): I see that two first piecewise equations contain terms that are either completely equal or symmetrical. I would like ...
1
vote
1answer
62 views

Solving ODE for emptying water tank, exclude branch with complex infinity

I'm trying to simulate a water tank. The dynamic of the system should be described by: DSolve[{y'[x] == Piecewise[{{-Sqrt[y[x]], 0 < y[x]}}, 0.], y[0] == 10}, y[x], x] An infinite object ...
1
vote
1answer
57 views

Solving a complicated time-dependent function

I want to solve the following time-dependent system of equations: ...
2
votes
0answers
45 views

Piecewise PDE Over 3 Regions with Continuity Boundary Conditions

I am using Wolfram Language for the first time for my research and could really use some help! I am trying to find the analytical solution of a PDE which has piecewise constants and a piecewise input. ...
4
votes
1answer
118 views

Problem with NDSolve and piecewise functions: Failure computing Filippov continuation

I am trying to solve a first order differential equation using NDSolve. The differential equation is ...
1
vote
1answer
39 views

Plotting iterates of a piecewise defined map

This is a follow up question to the one I asked here. I’ve succeeded in figuring out how to plot the first image of my piecewise defined transformation $T: [-1,1]^2 \to [-1,1]^2$, but now I want to ...
1
vote
1answer
48 views

Plotting image of piecewise-defined transformation

I have a transformation $T : [-1,1]^2 \to [-1,1]^2$ that is piecewise defined in the following way: \begin{align*} T(x,y) &= \big(a(x-1)+1,\:\left(b-cx\right)(y-1)+1\big) \quad \textrm{if } y > ...
3
votes
2answers
146 views

Approximate the piecewise constant with a smooth function

Let us first define a two regions as follow : inner=1;outer=2; reg1 = Disk[{0, 0}, inner]; reg2 = Annulus[{0, 0}, {inner, outer}]; glass=1.5;air=1; Now let's say I ...
2
votes
1answer
275 views

How to illustrate the optimal solution with kinked constraint?

I have a simple optimization problem with a linear, continuous constraint or a kinked constraint. The optimal solution is either a tangent point with f*<T or at the kink with f*=T. The standard ...
1
vote
0answers
55 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. ...
0
votes
0answers
19 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. ...
2
votes
2answers
102 views

Benefits/pitfalls of defining function that is discontinuous at a point “explicitly” vs using piecewise?

For example, suppose I wanted to define a function, f that is $f(x)=x^2$ except at $x=1$, where $f(x)=5$ Two ways I can define this are ...
3
votes
1answer
61 views

How to convert a Piecewise function in a HeavisideTheta function?

I want to convert a Piecewise function in a HeavisideTheta function in order to correctly evaluate its derivatives at the point of abrupt change and then integrate the result along the axis. How can I ...
1
vote
1answer
50 views

Both Dsolve and NDsolve for a differential equation failed

I tried both Dsolve and NDsolve for the following differential equation, it failed: It contains piecewise function ...
1
vote
2answers
69 views

How to plot HeavisideTheta with y=0.5 at x=0, and similar piecewise functions

How does one plot piecewise functions, with the ability to plot individual points along with open points to clearly show how values are defined at discontinuities? Example: Image Credit with the ...
2
votes
0answers
54 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 ...
0
votes
0answers
41 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. ...
1
vote
2answers
71 views

How to take limits in Fourier series?

I have a Fourier series which produces an impulse train of period j+1. In principle, it is given by ...
1
vote
1answer
94 views

Continuity and derivability of a multivariable function at a specific point

I have this function: f = Sqrt(Abs(x^2 - x*y)) So, how can I prove that it is derivable and/or continue in a point, like (0,0)?
1
vote
1answer
30 views

Plotting an iterated piecewise function with endogenous nodes

I am trying to plot a piecewise function that I can define recursively, where the nodes are endogenous as well. Basically, $f(l)=a^{t}$ when $l \in \left( \frac{\mu}{\alpha^{t-1}(1-\alpha)+\mu(1-\...
0
votes
1answer
55 views

Error in drawing a Piecewise function!

I want to plot the piecewise function (FP), which is define as: $$FP=\cases{1,&$\text{Eta}<J$\\ \frac{1-\left| \text{Gam}\right| }{2}, &$\text{Eta}=J$\\ \frac{\left| \text{Gam}*J\...
2
votes
1answer
111 views

Limit of multivariate piecewise function

Let's say we have a multivariate piecewise function f[x1_,x2_]:=Piecewise[{{Sin[x1]/x1,x1>x2},{Sin[x2]/x2,x1<=x2}}] Now we want to determine the limit in f(0,...
1
vote
1answer
61 views

How to evaluate a multidimensional NIntegral in a range where certain conditions must be satisfied by the variables

I have a function f which looks similar to this : f[a_, b_, c_] := NIntegrate[sigma[a, b, c], {a, -valueA, valueA}, {b, -valueB, valueB}, {c, -valueC, valueC}] and ...
0
votes
1answer
63 views

How do I introduce an assumption when defining a piecewise function?

Define m as an integer. I want to specify a Piecewise function f[x,n] that takes value ...
1
vote
0answers
35 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
1answer
42 views

Should be a Piecewise function, a ConditionalExpression or Indeterminate, but it is a number

I apologize in advance for the lack of focus of my question. Consider the function: f[x_, y_] := x/(x + y); f[0,0] evaluates to ...
2
votes
0answers
102 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) = ...
1
vote
2answers
184 views

Finding the maximum of a piecewise function

I have the following piecewise function of the variable $e_f$: $$g(a,b,c,w,F,e_h,e_f)=\begin{cases} \frac{(c-a e_f) (e_f (4e_f w-a)+c)}{8 b e_f^2} & \left(e_f=e_h\land e_f>\frac{c}{a}\...
5
votes
1answer
65 views

Piecewise function not evaluating properly

I have a simple Piecewise function that defines a square pulse: ...
1
vote
1answer
58 views

ParametricNDSolve “delayed time” error message

Issue reported to Wolfram, Inc as a possible bug in Version 12.1; CASE:4554034. When trying to solve a system of delay-differential equations with ParametricNDSolve...
2
votes
2answers
74 views

Double integration with a piecewise function gives wrong result

I am attempting to solve a double integral $$I(t) = \int_0^t dt' \int_0^{t'} dt'' f(t'')$$ of a piecewise function of the type $$f(t) = \begin{cases}1 & \text{for } 0 \leq t < a \\ -1 & \...
1
vote
1answer
104 views

How to plot a thermodynamic cycle? [duplicate]

I try to plot a thermodynamic cycle with the data displayed using the tool, "Piecewise", but in the case of isochoric and isobaric processes, Mathematica shows nothing. Could someone please tell me ...
0
votes
0answers
47 views

Piecewise function and NDSolve [duplicate]

I'm trying to solve a system of differenial equations involving a piecewise function with NDSolve. I tried to define this function using Piecewise but the kernel ...
0
votes
1answer
51 views

Understand output of Integration

Could someone help me understand the output of the following Integration in Mathematica? Specifically, (a) what is the meaning of "True"? (b) Why is the answer in two parts which seem to overlap ...
0
votes
1answer
33 views

Export data from NIntegrate and Piecewise

I use the following to calculate my Integral. ...
6
votes
2answers
152 views

Best 5 segment piecewise linear fit

I'm trying to get a piecewise linear best-fit for the closing price of one of the stocks I'm interested in. The logic seems ok, and the workflow works for a straight-line (ie 2 pts, ie 1 segment) ...
3
votes
2answers
74 views

HeavisidePi Plot

how could i change This Plot to something like this plot each two plots are concatenation of HeavisidePi The code for the first plot is : ...
2
votes
1answer
54 views

Why does HeavisideTheta not have an implicit piecewise expansion?

The Heaviside step function implicitly expands to a piecewise function: UnitStep[t - 3] // PiecewiseExpand $$ \begin{cases} 1 & t\geq 3 \\ 0 & \text{...
4
votes
1answer
76 views

TransformedRegion with piecewise function

Is it possible to use TransformedRegion with a Piecewise defined function? I tried the following, but it doesn't work and I don'...
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: ...
1
vote
0answers
39 views

Solving a Piecewise ODE [closed]

I am attempting to solve a piecewise ODE. $y' = \begin{cases} -1 & \text{for $y \geq 0$}\\ 1 & \text{for $y < 0$} \end{cases}, \qquad y(0)=0, \qquad x \in [0,1]$ I have attempted solving ...

1
2 3 4 5
9