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
3 votes
2 answers
84 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 <...
  • 209
2 votes
1 answer
71 views

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

The given function is This function is plotted to be ...
  • 664
7 votes
2 answers
239 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,070
-4 votes
1 answer
87 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
112 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
47 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
51 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
87 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
52 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
46 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
65 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
142 views

FunctionPeriod for functions defined in a Piecewise manner

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

Plot discontinuities use Piecewise

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

How to define function which changes at certain condition

...
5 votes
1 answer
144 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 ...
  • 443
2 votes
2 answers
72 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: ...
  • 857
4 votes
4 answers
189 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
54 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
35 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
188 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-...
  • 791
2 votes
1 answer
116 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
0 votes
0 answers
48 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 ...
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 ...
  • 11
0 votes
1 answer
123 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
133 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
128 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
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 ...
  • 663
1 vote
1 answer
97 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 ...
  • 663
1 vote
1 answer
83 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, ...
  • 99
3 votes
1 answer
55 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
5 votes
2 answers
143 views

Using Piecewise to create a periodic waveform

I want to create a piecewise function that repeats after t=T. ...
  • 19.3k
4 votes
2 answers
100 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 ...
0 votes
1 answer
85 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 : <...
  • 101
0 votes
1 answer
49 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}}]; ...
0 votes
0 answers
86 views

piecewise vector field and composition of piecewise functions

I have the following vector field ...
  • 41
0 votes
1 answer
62 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 ...
  • 1
0 votes
1 answer
70 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 &...
-2 votes
1 answer
78 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
0 votes
0 answers
38 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: ...
0 votes
0 answers
96 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
2 answers
100 views

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

I have the following expression with many Sign functions: ...
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: ...
1 vote
1 answer
59 views

How to solve Piecewise function in Reduce?

Here I have a Piecewise Function: ...
4 votes
2 answers
153 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 ...
  • 31.2k
0 votes
0 answers
68 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 ...
  • 215
0 votes
1 answer
131 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{...
  • 313
-1 votes
1 answer
110 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 ...
  • 3
1 vote
3 answers
201 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
2 3 4 5
10