# Questions tagged [piecewise]

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

492 questions
Filter by
Sorted by
Tagged with
33 views

### How to simplify the conditions of a Piecewise function (Maximize output)?

I'm new on the forum and on Mathematica. I'm studying the crest of a function of the three variables c, e, g3. With "crest" I mean I'm maximizing the function only over c, keeping the ...
176 views

### How to draw a VectorPlot where each component is a piecewise function？ [closed]

I want to draw a VectorPlot where each component is a piecewise function in Mathematica14.0, such as ...
• 71
1 vote
112 views

• 11
524 views

### How can I plot this piecewise function? [closed]

How can I plot function $g(x)$ given below: The following attempt I have tried does not work and returns errors: ...
• 4,315
164 views

### How is this type of piecewise function represented and calculated? [closed]

How is this type of piecewise function as follows in the picture represented and calculated? Use: ...
• 4,315
1 vote
151 views

### How can I interpolate a piecewise constant function?

Let the given set of points ...
• 603
125 views

### Put a standalone wall barrier inside a 2D square well potential

Here is the code for the 2D square well potential: v[x_, y_] := Piecewise[{{1, 58 < Abs[x]}, {1, 58 < Abs[y]}}]; Plot3D[v[x, y], {x, -70, 70}, {y, -70, 70}] Is Piecewise the right function to ...
• 1,637
82 views

### Using NDSolve on piecewise-defined system of ODEs

I'd like to use NDSolve to solve a system of n coupled 1st-order linear ODEs expressed in matrix-vector form, but which are definied piecewise in n-space (in particular, to represent different linear ...
47 views

### How to plot this two variables piecewise function?

I was wondering if there is a suitable way to plot the function $$f(x, y) = \begin{cases} x & y < x^3 \\\\ y & y \geq x^3 \end{cases}$$ Maybe with piecewise? But it's a two variables ...
• 321
50 views

### Piecewise Boundary Condition for axisymmetric heat equation [duplicate]

I'm trying to solve the 2D axisymmetric heat equation, where only one section of the tube is being heated up. I have written the following code below: ...
• 103
452 views

### How can one build this kind of graphics? What kind of plot is it?

i want to know how can i build this kind of plot? its a graphic of Moment -150 to 150(H.m)in fuction of time from 0 to 6 seconds.
• 21
166 views

### RuleDelayed (:>) involving Piecewise leads to Piecewise::pairs warning in ReplaceAll (/.)

When I write a replacement rule like this: Piecewise[{{x^2, x < 0}}] /. Piecewise[a_, b___] :> Piecewise[a, b] It works fine, but I get the unexpected ...
• 3,003
1 vote
119 views

### How to synatx a piecewise where x=0 is undefined?

How to write the synatx for a piecewise where x=0 is undefined in the domain of the function, and according to the below conditions ? y := Piecewise[{{1, 0 < x < Pi}, {-1, -Pi < x < 0}}]
140 views

### Combining two interpolating functions via Piecewise or If is very slow

For a given set of parameters $(i,l,m)$ I have a function which has been evaluated on a grid $x \in (-2,2)$. Since this function is not smooth (only continuous) at the "interface" $x=0$, I ...
• 1,511
84 views

### Piecewise Recursive function with 2 arguments

The following code is not working for argument nn>1. Hold statement Hold[0.62+v0[1,0]] come as output for v0[2,0]. ...
• 43
39 views

### NDSolve not handling discontinuity in initial condition [duplicate]

I am trying to solve a PDE in two variables z and t. This PDE is from "Universality of Capillary Rise" by Zhou and Doi (2020). There is additonally a parameter n that can take positive ...
• 407
62 views

### Simplifying Piecewise Function Evaluates Irrelevant Cases

Consider the following function: ...
73 views

### How to fit piecewise functions with unknown domain?

Thank you for your comments, I will discribe the question in more detail. I have a piecewise function as below and I'm looking for the parameters :...
• 1
1 vote
64 views

### Piecewise function with form determined by current value

I would like to create a piecewise function that determines the dynamics of a variable $x_t$ as follows: Given a starting value $x_0$ and a parameter $\hat{x}$: ...
• 479
173 views

### Accurate and efficient sampling of interpolated functions

Suppose we are given two interpolated functions ...
• 487
169 views

### Creating FormPage Calculator with a Piecewise Function

I am trying to make a calculator to help my mom calculate late fees in our rental property business. Thus, in this calculator all you're supposed to do is input the date on which the tenant is paying ...
• 33
124 views

### Finite Jerk Motion Profile

I try to define a function to plot a motion profile with constant jerk. It seems that my function doesn't work. Would you help me to debug my function ? I guess my issue comes from a bad management of ...
• 1,099
121 views

### Plot a sequence of functions in one plot

I would like to plot a sequence of functions in one plot. My function is defined piecewise: ...
• 277
193 views

### Defining Piecewise function using an Interval object

I was trying to define a Piecewise function using a previously defined Interval object (that is the union of several intervals). However, I realised that I wasn't ...
• 153
94 views

### Derivative of piecewise function returns one more case

I define the following piecewise function: U[c_,n_,g_,p_]:=Piecewise[{{c^(1-g)/(1-g)-n^(1+p)/(1+p),g!=1}, {Log[c]-n^(1+p)/(1+p),g==1}}] When I take the derivative <...
• 479
133 views

### How to plot a function with different conditions (if or which or piecewise)

The given function is This function is plotted to be ...
• 2,446
376 views

### How to remove branches in Piecewise with measure 0

I am doing Convolve over UnitTriangle in 2 dimensions and the resulting piecewise function has conditions with measure zero (...
• 2,080
94 views

### I can't plot a certain solution

DSolve[{x''[ u] == -(1/ 2)*(2*1*(\[CapitalTheta] (u + a) - \[CapitalTheta] (u - a)))*x[u]}, {x[u]}, {u}]; x[u] /. {{x[u] -> C[1] Cos[Sqrt[2] Sqrt[a] u Sqrt[[...
1 vote
145 views

### NDSolve with piece-wise function and BVP

How to numerically solve a system of differential equation with boundary conditions and piece wise affine functions ? Consider the following system of differential equations from some optimal control ...
• 11
122 views

### How to plot the derivative of a piecewise discontinuous function (by excluding discontinuity points)?

With the following code I am trying to get a plot for the derivative of the ftot1 function, which is a piecewise discontinuous function defined as the sum of other two piecewise discontinuous ...
• 1
68 views

### Using DSolve, For A System With A Piecewise Function, And For Given Boundary & Continuity Conditions

I'm trying to solve a system of ODE's, analytically, to find the integration constants. The system is the following (with zUpper=125 000 and zLower= 200 000). For 0 <= z <= zUpper: 3 T''[z] == 0....
1 vote
113 views

### Derivative of long expression renders Piecewise[…<<…>>…] in Jupyter notebook

My mathematical problem is to solve the optimization problem: $$Max_{u} \quad \mathbb{E}[\gamma S-S^2]$$ where $$S= A_0 u X+a-\max(\alpha u X+b,0)$$ with $\gamma,A_0,a,\alpha,b$ some constants and \$X\...
• 123
1 vote