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

Slot a piecewise function [closed]

I would like to use slots while defining a Piecewise function. ...
user avatar
  • 305
0 votes
0 answers
31 views

Using the recursion index to compare with a value in another list

I am trying to generate an arrivals and departures plot for a signalised junction with the following parameters: lambda: rate of arrival c: cycle length of traffic lights g: length of time signal is ...
user avatar
1 vote
2 answers
160 views

Is there a way to fit a piecewise linear function to a list?

I need to find a piecewise linear function that is a proper approximation for sunrise/sunset times of each day of year. Due to some limitations, I cannot use any trigonometric functions. So the sine-...
user avatar
  • 789
2 votes
1 answer
94 views

Piecewise smooth rectangular pulse

I am wondering how to create a rectangular pulse with a non linear falling edge on one side, and straight line sloping from the falling edge (the red line). So far I have managed to get the plot ...
user avatar
  • 31
0 votes
0 answers
44 views

How to plot Piecewise function using symbols as axis

I want to make a plot of V(r) vs r with my x-axis being in units of R, and my y-axis in units of q/(4πqεR). I used discrete values of q and R to get the plot to work but I would prefer if they could ...
user avatar
0 votes
2 answers
81 views

Mathematica Issue [closed]

I'm completely new to Mathematica, and I'm facing an issue. So basically, I know that Out[43]'s answer is 1+2a+3b. And out[44] is a+b. I dont know why it's giving me a different answer here. Can ...
user avatar
  • 11
0 votes
1 answer
99 views

How to obtain the convolution of these functions?

I am starting to use Mathematica. I wanted to compute $$\nabla F*\phi(x),\;x\in\mathbb{R^2}$$ where $F(x)=\ln\|x\|$ and $\phi(x)=\chi_{B(0,2)}(x)$. I am a new user of this software, so I don't know ...
user avatar
  • 101
4 votes
1 answer
125 views

Mathematica 12.1 integrates functions individually but not their sum

I found something odd in MMA 12.1 when symbolically integrating DiracDelta and Piecewise. These functions are integrated individually but not their sum. The following code ...
user avatar
1 vote
1 answer
118 views

System of ODE with piecewise functionals

I am trying to solve a system of ODE. I am new to Mathematica What I am trying to get is the plot labelled 1 & 2. ...
user avatar
  • 13
0 votes
1 answer
31 views

Manipulate plot with Eplilog where location of Point is given by a function outside of the Plot/Manipulate command

Consider a piecewise function such as f = Piecewise[{{x, 0 <= x <= x1}, {Sin[\[Pi] x], x1 < x <= x2}}] I want to plot f using Manipulate and add a ...
user avatar
  • 663
1 vote
1 answer
66 views

Colour plot based on x-axis value

I am trying to adapt [this solution for colouring the different sections of a Piecewise function] I want to colour based on the x-axis value. I have two functions I want to do this for, one is ...
user avatar
  • 663
1 vote
1 answer
60 views

NSolve for Piecewise function

I have a piecewise function. I want to find the root of this function with the NSolve command. But, it does not give me any result and it just prints the equation. I can find the root with FindRoot, ...
user avatar
  • 99
3 votes
1 answer
51 views

How to use ConvexOptimization on a piecewise function?

I define a simple piecewise convex function, but ConvexOptimization does not take it as a valid input: ...
user avatar
  • 332
5 votes
2 answers
119 views

Using Piecewise to create a periodic waveform

I want to create a piecewise function that repeats after t=T. ...
user avatar
  • 14.2k
4 votes
2 answers
98 views

Plot and differentiate a piecewise vector function [closed]

Consider the map $f:\mathbb R^2\to \mathbb R$ defined as $$ f(x,y)=\begin{cases} \|(x,y)\|^2\sin(1/\|(x,y)\|) & (x,y)\neq0 \\ 0 & (x,y) =0\\ \end{cases}$$ I am trying to get a ...
user avatar
0 votes
1 answer
77 views

Plotting a piecewise multivariable function [closed]

I want to plot the following function : \begin{equation} f(x,y)=\begin{cases} \frac{xy(x^2-y^2)}{x^2+y^2}, \; (x,y)\neq(0,0)\\ 0, \; (x,y)=(0,0)\end{cases} \end{equation} I tried the following : <...
user avatar
  • 101
0 votes
1 answer
43 views

Difficult on integration the normalization of a piecewise function

I have a little problem; I have defined the following Piecewise-function in the variables {x,L,w}: f[x_, L_, w_] := Piecewise[{{x w (L - x), 0 <= x <= L}}]; ...
user avatar
0 votes
0 answers
74 views

piecewise vector field and composition of piecewise functions

I have the following vector field ...
user avatar
  • 41
0 votes
1 answer
50 views

I have a variable error and was curious to see if it's due to piecewise functions?

So I have a displacement function sigx as a function of "t" (time) and sig.pre (pre-stress). At some time "dx": force "fo" goes to 0, and the same displacement function ...
user avatar
  • 1
0 votes
1 answer
67 views

NIntegrate seems to not recognize multiplication of Piecewise function and f[t_]:= function, Why?

Considering inputs: vti={0, 1.5, 2.4, 5.0675, 7.735, 10}; Vscc=1.5; PSA=0.025; f=0.6; m=10; I defined a function "pwtemp2", using "FC1" and &...
user avatar
-2 votes
1 answer
73 views

how to find and b piecewise function mathamatica [closed]

how would i find a,b for how would i write this in Mathematica to get a and b
user avatar
0 votes
0 answers
35 views

Piecewise[ ] for joining InterpolationFunction objects?

I want to combine InterpolationFunction objects, results of an NDSolve in a loop, into one function. This is my code: ...
user avatar
0 votes
0 answers
79 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}, & \...
user avatar
1 vote
2 answers
98 views

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

I have the following expression with many Sign functions: ...
user avatar
0 votes
1 answer
57 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: ...
user avatar
1 vote
1 answer
55 views

How to solve Piecewise function in Reduce?

Here I have a Piecewise Function: ...
user avatar
4 votes
2 answers
147 views

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

Bug introduced after 9.0.1, persisting through 12.3.1. Fixed in 13.0 I have identified a bug in DSolve when differential equation includes a ...
user avatar
  • 28.6k
0 votes
0 answers
56 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 ...
user avatar
  • 215
0 votes
1 answer
65 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{...
user avatar
  • 313
-1 votes
1 answer
109 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 ...
user avatar
  • 3
1 vote
3 answers
191 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$...
user avatar
2 votes
1 answer
111 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: ...
user avatar
  • 403
1 vote
1 answer
58 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 <...
user avatar
0 votes
0 answers
34 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 ...
user avatar
0 votes
0 answers
47 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) ...
user avatar
  • 213
1 vote
1 answer
54 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}$ ...
user avatar
  • 1,576
-1 votes
5 answers
92 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 ...
user avatar
  • 4,791
1 vote
1 answer
58 views

Different kind of PlotStyle via Piecewise

I have a Piecewise. For vertical line I have to add Exclusions -> None. ...
user avatar
0 votes
2 answers
105 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: ...
user avatar
0 votes
1 answer
88 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. <...
user avatar
  • 55
1 vote
0 answers
104 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 ...
user avatar
  • 205
3 votes
1 answer
69 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: ...
user avatar
  • 7,759
1 vote
1 answer
69 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 ...
user avatar
1 vote
1 answer
71 views

Solving a complicated time-dependent function

I want to solve the following time-dependent system of equations: ...
user avatar
  • 1,723
2 votes
0 answers
64 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. ...
user avatar
4 votes
1 answer
184 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 ...
user avatar
  • 41
1 vote
1 answer
53 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 ...
user avatar
  • 125
1 vote
1 answer
52 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 > ...
user avatar
  • 125
3 votes
2 answers
220 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 ...
user avatar
2 votes
1 answer
308 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 ...
user avatar
  • 121

1
2 3 4 5
9