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
0answers
43 views

Summing `Piecewise` function with many cases efficiently

Schematics of the question: I have two piecewise functions $f_1$ and $f_2$ as $$f_1 = \begin{cases} \textrm{value 1}, & \textrm{case 1}, \\ \vdots & \vdots \\ \textrm{value 1024}, & \...
1
vote
2answers
84 views

Simplifying expressions with `Sign` functions to a single piecewise format

I have the following expression with many Sign functions: ...
0
votes
1answer
54 views

Single computation is fast, but 6 computations are extremely slow

I have an expression that involves many Sign functions. I want to expand this in the piecewise format. My function is: ...
1
vote
1answer
49 views

How to solve Piecewise function in Reduce?

Here I have a Piecewise Function: ...
3
votes
1answer
98 views

What is the scope of the bug where Piecewise breaks DSolve?

Bug introduced after 9.0.1, persisting through 12.3.1. I have identified a bug in DSolve when differential equation includes a ...
0
votes
0answers
46 views

NDSolve with Piecewise function consideres some value inside Piecewise as Indeterninate

I'm solving a PDE, with one coefficient being piecewise. The issue appears to be that NDSolve somehow consideres piesewise boundary as ...
0
votes
1answer
48 views

Piecewise Function Definition

I am new to Mathematica, and I am unsure on how to do this. I am working with piecewise function $$ f_N(x) := \begin{cases} 1 & \text{if}\;\;x = j\sqrt{3}, \quad j=1,...,N \\ 0 & \text{...
-1
votes
1answer
108 views

Did Mathematica make a mistake or was it me?

I'm having a little trouble with Mathematica. There are two expressions that should be equal over a given region. Each of which consists of three terms that should be equal individually: term1 of ...
1
vote
3answers
181 views

How solve this nonlinear equations system by 12 unknowns?

We consider the following integral equation of mixed type: $x[t]=\frac{t^4}{6} -\frac{t^3}{3} +t+\Sigma_{\mu=1}^2\int_{0}^t k_\mu[t,s]G_\mu[s,x[s]]ds ,0\leq t\leq 1 $ ; (1) where $k_1 [t, s] = s^3$...
1
vote
1answer
73 views

Maximization of piecewise function

I'm trying to maximize piecewise functions with parameters but haven't been able to do so. Here is a minimum example: ...
1
vote
1answer
55 views

How to plot a piece-wise function like this: f[x]=1 when -1<=x<=1, and f[x]=0 when x>1 or x<-1

I want to plot a piece-wise function like this: f[x]=1 when -1<=x<=1, and f[x]=0 when <...
0
votes
0answers
33 views

Issue with Piecewise Parametric Plotting

I am trying to make a parametric plot of a piecewise function that is defined locally. For some odd reason, Mathematica will only plot the first two pieces of the piecewise function. If I plug in ...
0
votes
0answers
46 views

Different results from polar and cartesian forms of a function?

I am trying to write up and study the given function: by the following Mathematica input (with N=5 and not infinity) ...
1
vote
1answer
46 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
5answers
85 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
53 views

Different kind of PlotStyle via Piecewise

I have a Piecewise. For vertical line I have to add Exclusions -> None. ...
0
votes
2answers
87 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
86 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
63 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
62 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
29 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
64 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
63 views

Solving a complicated time-dependent function

I want to solve the following time-dependent system of equations: ...
2
votes
0answers
51 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
132 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
46 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
50 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
176 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
290 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
59 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
24 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
103 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
87 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
53 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
73 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
57 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
45 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
78 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
110 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
58 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
148 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
64 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
74 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
39 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
56 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
111 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
2answers
231 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
71 views

Piecewise function not evaluating properly

I have a simple Piecewise function that defines a square pulse: ...
1
vote
1answer
62 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...

1
2 3 4 5
9