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
1 answer
66 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
34 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 ...
  • 217
0 votes
0 answers
18 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
49 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
2 votes
1 answer
447 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
153 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 ...
  • 2,923
1 vote
1 answer
68 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}}]
1 vote
2 answers
98 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,317
4 votes
1 answer
68 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
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 ...
  • 175
0 votes
0 answers
38 views

Define regular function as difference of two piecewise functions

Consider a piecewise smooth function, ...
  • 1,317
3 votes
1 answer
54 views

Simplifying Piecewise Function Evaluates Irrelevant Cases

Consider the following function: ...
0 votes
0 answers
64 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
0 votes
1 answer
39 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}$: ...
  • 321
0 votes
1 answer
78 views

Accurate and efficient sampling of interpolated functions

Suppose we are given two interpolated functions ...
1 vote
1 answer
94 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 ...
  • 23
-1 votes
1 answer
105 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,079
3 votes
2 answers
110 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: ...
  • 257
0 votes
2 answers
78 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
3 votes
2 answers
91 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 <...
  • 321
2 votes
1 answer
107 views

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

The given function is This function is plotted to be ...
  • 1,094
7 votes
2 answers
280 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
-4 votes
1 answer
91 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
122 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
0 votes
1 answer
80 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
0 votes
0 answers
58 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
96 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
1 answer
57 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 ...
  • 13
0 votes
0 answers
58 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
47 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 ...
  • 137
3 votes
2 answers
70 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
160 views

FunctionPeriod for functions defined in a Piecewise manner

To create a minimal example, consider a piecewise function: ...
  • 28.9k
7 votes
1 answer
151 views

Plot discontinuities use Piecewise

how can I get a plot like this? I tried with in Mathematica 13.0: ...
3 votes
1 answer
61 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
92 views

How to define function which changes at certain condition

...
5 votes
1 answer
152 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 ...
  • 453
2 votes
2 answers
74 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: ...
  • 867
4 votes
4 answers
200 views

Parts of a Piecewise Matrix Function in NDSolve

First time posting. Reproducing the Problem I'm relatively new to Mathematica (using v.12.3), and working on a project. My problem can be reproduced with this. ...
-2 votes
1 answer
58 views

How to convert traditional form of piecewise output into input piecewise function? [closed]

I have an output in this form. Let's say the f[s_,t_]:=output; When I try to calculate points at s, t e.g f[0.1,0.1], the output is still the same instead of any point. but if I convert this output ...
0 votes
0 answers
37 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 ...
1 vote
2 answers
221 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-...
  • 835
2 votes
1 answer
149 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 ...
  • 31
-1 votes
2 answers
89 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 ...
  • 9
0 votes
1 answer
198 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 ...
  • 101
4 votes
1 answer
136 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 ...
1 vote
1 answer
148 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. ...
  • 13
0 votes
1 answer
35 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 ...
  • 673
1 vote
1 answer
131 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 ...
  • 673
1 vote
1 answer
89 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, ...
  • 111
3 votes
1 answer
63 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: ...
  • 332

1
2 3 4 5
10