Questions tagged [piecewise]
Questions about the Piecewise function, which is represented by different expressions for different ranges of values of its independent variable.
482
questions
2
votes
1
answer
71
views
How to transform the regions in which a piecewise function are defined?
I have a function f[x,y,z] that has a piecewise definition, i.e., its values depends on the ranges of the arguments. Now suppose I have a coordinate transformation <...
0
votes
0
answers
62
views
Improving the curve of a quadratic spline interpolation
I have these data and I want to make a curve using quadratic spline interpolation. I am successful in computing the equations and plotting the curves. However, I noticed that the peaks of the curves ...
0
votes
1
answer
34
views
Piecewise integration doesn't evaluate
I'm trying to integrate the following function:
$$q(d, \theta) = q_x(d, \theta) + q_y(d, \theta) - 2q_x(d, \theta) q_y(d, \theta)$$
where $q_x(d, \theta) = \min\left(2 - d\cos\theta, d\cos\theta\right)...
0
votes
1
answer
58
views
Finding the maximum of a symbolic piecewise function
I have the function:
coded as:
...
4
votes
1
answer
61
views
Confusing cases in Piecewise
The following
FullSimplify[Integrate[Exp[I ω t] Sin[ω x]/ω, {ω, 0, ∞},
Assumptions -> t > 0 && x > 0]]
gives a piecewise output of the form
I ...
0
votes
0
answers
22
views
Problem with Piecewise function applying to matrix of polynomials
I have a matrix of a polynomial - function f
f[t_, i_] := wielomianSpline[t, tx[[i]], wspfi[[i]]];
and I want to evaluate the ...
2
votes
1
answer
99
views
Need an equation for modeling Tytler's Cycle
In all cultures over all time there appears, in different languages for different countries, the maxim "Shirtsleeves to shirtsleeves in three generations." This is a function with three ...
0
votes
0
answers
36
views
Issue with piecewise functions and lists of rules
I have a list of data that I am connecting with a simple piecewise function. I then want to evaluate the piecewise function at a different list of points. I can do it the long way, but I am wondering ...
1
vote
0
answers
41
views
Solving first-order ODE with piecewise component
I have an ODE I'd like to find an analytical solution to,
$$
\frac{dZ}{dt}=-\alpha Z+\frac{\beta X^n}{(1+X^n)(1+Z^n)} $$
where
$$
X(t) =
\begin{cases}
1 & 1 \leq t \leq 6 \\
...
6
votes
2
answers
510
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:
...
3
votes
1
answer
156
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:
...
1
vote
2
answers
143
views
How can I interpolate a piecewise constant function?
Let the given set of points
...
4
votes
1
answer
124
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 ...
0
votes
1
answer
76
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 ...
2
votes
1
answer
42
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 ...
0
votes
0
answers
29
views
Issues while using WhenEvent and HeavisideTheta inside NDSolve
What I am doing?
Integrating a piece-wise ODE using NDSolve. The piece-wise part is governed by HeavisideTheta.
Objective?
The goal is to update numerical values when an event is detected. This is ...
0
votes
0
answers
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:
...
2
votes
1
answer
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.
4
votes
1
answer
160
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 ...
1
vote
1
answer
104
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}}]
2
votes
2
answers
119
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 ...
4
votes
1
answer
79
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].
...
0
votes
0
answers
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 ...
0
votes
0
answers
43
views
Define regular function as difference of two piecewise functions
Consider a piecewise smooth function,
...
3
votes
1
answer
60
views
Simplifying Piecewise Function Evaluates Irrelevant Cases
Consider the following function:
...
0
votes
0
answers
69
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
vote
1
answer
62
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}$:
...
0
votes
2
answers
165
views
Accurate and efficient sampling of interpolated functions
Suppose we are given two interpolated functions
...
1
vote
1
answer
155
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 ...
-1
votes
1
answer
115
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 ...
3
votes
2
answers
114
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:
...
0
votes
2
answers
145
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 ...
3
votes
2
answers
93
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
<...
2
votes
1
answer
126
views
How to plot a function with different conditions (if or which or piecewise)
The given function is
This function is plotted to be
...
7
votes
2
answers
342
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 (...
-4
votes
1
answer
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
2
answers
134
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 ...
0
votes
1
answer
116
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 ...
0
votes
0
answers
66
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
1
answer
107
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\...
1
vote
1
answer
60
views
Vectorplot shows empty result
I've tried to draw a vector plot with piecewise functions, but it shows empty result.
When I don't use piecewise functions, Vectorplot works well..
I can't figure out what the problem is.
I would ...
0
votes
0
answers
61
views
Numerical integration of iterated integral with piecewise integrand
I need to plot the following integral:
$$
\Omega(t)=\int^{x_1(t)}_0 {4\pi x_i^2\rho(x_i,t=t_s)\int^\infty_04\pi x^2\rho_{reg}(x_i,x,t)dx}dx_i
$$
where
$$
\rho(x_i,t)=
\left\{
\begin{...
1
vote
0
answers
50
views
A piecewise inequality not simplified to True [closed]
In = Simplify[-a + Piecewise[{{-b, t > c}}] < 0, {a > 0, b > 0, c > 0}]
Out = Piecewise[{{-b, t > c}}] < a
Why the result is not evaluated to ...
3
votes
2
answers
81
views
How do I integrate this piecewise function with Mathematica?
I came across the question of what percent of numbers from 0 to 1 have a logerithm whose floor is even. What I did was I made a piecewise function: ...
3
votes
2
answers
186
views
FunctionPeriod for functions defined in a Piecewise manner
To create a minimal example, consider a piecewise function:
...
7
votes
1
answer
167
views
Plot discontinuities use Piecewise
how can I get a plot like this?
I tried with in Mathematica 13.0:
...
3
votes
1
answer
68
views
Piecewise Functions from List of Functions
I have multiple functions from two different NDSolves that I would piece together. Here is a working minimal example:
...
2
votes
1
answer
97
views
5
votes
1
answer
178
views
How can I remove the outermost pair of brackets enclosing a Piecewise function when it occurs in an equation?
Recently I have been annoyed by an automatic formatting in MMA, that is when a Piecewise function occurs in an equation, it will be enclosed by a pair of brackets automatically by MMA, although when ...
2
votes
2
answers
78
views
Piecewise based on the length of the list
I want to create a piecewise function that depends on the length of the list.
Let's say I have a list, and a corresponding piecewise function:
...