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
1answer
44 views

How do I introduce an assumption when defining a piecewise function?

Define m as an integer. I want to specify a Piecewise function f[x,n] that takes value ...
1
vote
0answers
32 views

Find edges of a piecewise curve

I have a continuous function f[x], and I want to calculate the coordinates of the discontinuities in Round[f[x]]. My code needs ...
1
vote
1answer
31 views

Should be a Piecewise function, a ConditionalExpression or Indeterminate, but it is a number

I apologize in advance for the lack of focus of my question. Consider the function: f[x_, y_] := x/(x + y); f[0,0] evaluates to ...
2
votes
0answers
83 views

How do I create a piecewise function using Do[] or While[]?

The following non-linear circuit is an uncontrolled three-phase full-wave 6-pulse rectifier. The inputs are $v_{an}(t) = V_m \sin (\omega t)$, $v_{bn}(t) = V_m \sin (\omega t-120°)$ and $v_{cn}(t) = ...
1
vote
2answers
114 views

Finding the maximum of a piecewise function

I have the following piecewise function of the variable $e_f$: $$g(a,b,c,w,F,e_h,e_f)=\begin{cases} \frac{(c-a e_f) (e_f (4e_f w-a)+c)}{8 b e_f^2} & \left(e_f=e_h\land e_f>\frac{c}{a}\...
5
votes
1answer
45 views

Piecewise function not evaluating properly

I have a simple Piecewise function that defines a square pulse: ...
1
vote
1answer
54 views

ParametricNDSolve “delayed time” error message

Issue reported to Wolfram, Inc as a possible bug in Version 12.1; CASE:4554034. When trying to solve a system of delay-differential equations with ParametricNDSolve...
2
votes
2answers
54 views

Double integration with a piecewise function gives wrong result

I am attempting to solve a double integral $$I(t) = \int_0^t dt' \int_0^{t'} dt'' f(t'')$$ of a piecewise function of the type $$f(t) = \begin{cases}1 & \text{for } 0 \leq t < a \\ -1 & \...
1
vote
1answer
62 views

How to plot a thermodynamic cycle? [duplicate]

I try to plot a thermodynamic cycle with the data displayed using the tool, "Piecewise", but in the case of isochoric and isobaric processes, Mathematica shows nothing. Could someone please tell me ...
0
votes
0answers
46 views

Piecewise function and NDSolve [duplicate]

I'm trying to solve a system of differenial equations involving a piecewise function with NDSolve. I tried to define this function using Piecewise but the kernel ...
0
votes
1answer
44 views

Understand output of Integration

Could someone help me understand the output of the following Integration in Mathematica? Specifically, (a) what is the meaning of "True"? (b) Why is the answer in two parts which seem to overlap ...
0
votes
1answer
24 views

Export data from NIntegrate and Piecewise

I use the following to calculate my Integral. ...
6
votes
2answers
113 views

Best 5 segment piecewise linear fit

I'm trying to get a piecewise linear best-fit for the closing price of one of the stocks I'm interested in. The logic seems ok, and the workflow works for a straight-line (ie 2 pts, ie 1 segment) ...
3
votes
2answers
60 views

HeavisidePi Plot

how could i change This Plot to something like this plot each two plots are concatenation of HeavisidePi The code for the first plot is : ...
2
votes
1answer
44 views

Why does HeavisideTheta not have an implicit piecewise expansion?

The Heaviside step function implicitly expands to a piecewise function: UnitStep[t - 3] // PiecewiseExpand $$ \begin{cases} 1 & t\geq 3 \\ 0 & \text{...
4
votes
1answer
67 views

TransformedRegion with piecewise function

Is it possible to use TransformedRegion with a Piecewise defined function? I tried the following, but it doesn't work and I don'...
0
votes
0answers
32 views

Plotting a piecewise function MRI problem

I have this M.R.I. question, and i need to plot a function with some 'a' and 'b' parameters and 't' as a variable: ...
1
vote
0answers
30 views

Solving a Piecewise ODE [closed]

I am attempting to solve a piecewise ODE. $y' = \begin{cases} -1 & \text{for $y \geq 0$}\\ 1 & \text{for $y < 0$} \end{cases}, \qquad y(0)=0, \qquad x \in [0,1]$ I have attempted solving ...
1
vote
0answers
21 views

```PiecewiseExpand``` doesn't work as expected with a recursive function

In an effort to examine this question on Math.SE, I defined the following functions ...
0
votes
0answers
24 views

Find and indicate the minimum of a piecewise function in the `Plot3D` diagram

I'm trying to indicate in my Plot3D diagram the minimum level of the dependent variable and the corresponding levels of two independent variables. More specifically,...
0
votes
1answer
48 views

Using subscripted symbol affects integration — why?

Below is a sample program that shows that Integrate is giving different results depending on whether I name the variable duration1 or ...
0
votes
1answer
37 views

Why do Integrate and DSolve/DSolveValue yield such complex expressions for Piecewise functions?

This code uses two different methods for integrating a very simple piecewise function but yields surprisingly complicated integrals: ...
2
votes
1answer
53 views

Piecewise integration not giving continuous result

I'm trying to integrate a piecewise function symbolically and I'm ending up with discontinuities which is surprising since the help mentions that constants are determined to ensure continuity. If I ...
1
vote
2answers
75 views

Graphing a Fourier Series

First off, I have created the following Fourier series for the below equation/condition: $$f(t) = \begin{cases} 0, & 0<t<1 \\ 1, & 1<t<2 \end{cases} $$ My Fourier Equation for ...
0
votes
1answer
22 views

Limiting the Domain of a Function

Currently, I am trying to plot (using Mathematica) the following function: $$f(t) = \begin{cases} 0, & 0<t<1 \\ 1, & 1<t<2 \end{cases} $$ And, to try to plot this, I did some ...
0
votes
0answers
40 views

Bad Integral evaluation for Piecewise function

I have been trying to evaluate this symbolic function: f[ρ_, R_, α_, yp0_, yp_] := R*((ρ - R*Cos[α])^2 + (R*Sin[α])^2 + (yp-yp0)^2)^(-(1/2)); Mathematica can ...
2
votes
1answer
55 views

Plot of Piecewise function is slow

While working on answer for question (here) I found out that the Plot is incredible slow for Piecewise function: Some preparations: ...
0
votes
1answer
46 views

Plotting Piecewise function?

I am facing a problem in plotting the Piecewise function. I simplified my problem to take the following form: where \[Sigma][i] are Pauli matrices. My code is: <...
0
votes
1answer
44 views

How do I combine a piecewise function within a parametric plot?

I'm trying to combine two functions together piecewise style, but nest that within a ParametricPlot function. Here's my code right now: ...
3
votes
3answers
78 views

count conditional items in list

I have a list of the form: {1,1, (1 if x>y, -1 if y>=x), -1} I want to count the number of 1's in the list. The output I'm looking for is something of the ...
2
votes
1answer
59 views

Forcing the fit of a nonlinear piecewise function to be continuous

I am trying to fit some data ...
3
votes
2answers
79 views
1
vote
1answer
50 views

find intersections of 2 Piecewise Functions in ImplicitRegion

How do I combine this two parts of a Piecewise functions? I have trouble join this with || ...
1
vote
2answers
36 views

Can someone tell me what is wrong with my code? [closed]

The code I am using to make my plot is: DiscretePlot[ Piecewise[{{1/((-2)^{x + 1}), x <= 3}, {1/32, x >= 4}}], {x, 0, 10}] Also, how do I change to color ...
1
vote
0answers
38 views

Need help plotting on Mathematica simple piecewise wave function from quantum physics (Quantum Physics, Griffiths, 2.7) [closed]

On Mathematica need to plot an initial wave function defined as... Psi(x,0) = Ax when 0 <= x <= a/2 Psi(x,0) = A(a - x) when a/2 <= x <= a Here is my attempted code... ...
3
votes
1answer
68 views

How to Refine HeavisideTheta or UnitStep?

Look at the following chunk of code: Assuming[x > 0, Refine@HeavisideTheta[x]] It yields 1. However the same method does ...
1
vote
0answers
55 views

Speed up Integrate around Max/Min or Piecewise

Integrate around a convex combination of two functions containing Min or Max or ...
6
votes
0answers
61 views

difference between right click and “copy as LaTeX” and directly using TeXForm

...
0
votes
2answers
76 views

how to rewrite conditions as conditions&& True

I have a result comes from Reduce a <= -2 || (1 < a < 2 && (x >= 1/3 (4 + 4 a))) || a >= 2 it has a ...
1
vote
1answer
45 views
0
votes
0answers
89 views

Using NDSolve and PieceWise for boundary conditions for coupled PDEs

I've decided to try and use PieceWise in my boundary conditions for my 4 coupled PDEs, but it doesn't seem to work out nicely. I'm receiving the error: NDSolve::overdet: There are fewer dependent ...
0
votes
0answers
79 views

Fit piecewise function

I want to fit my data with the following function ...
0
votes
1answer
35 views

ParametricPlot on Piecewise function not working with consecutive t values [closed]

I am trying to graph a piecewise function composed of a series of parametric cubic functions. I initially created a ParametricPlot for the first four pieces of the equation and it was working fine, as ...
0
votes
0answers
68 views

Fit a three-pulse sequence

I am wondering how to properly fit the three-pulse sequence shown below. I have tried a method which is fitting the three pulses with three polynominal functions seperately and then finding the x-...
5
votes
2answers
130 views

Integration of a piecewise function with parameters

Here is a simple piece-wise and continuous function: f[t_,a_,b_]:=Piecewise[{{a t,t<1},{a,t<1+b},{a(2+b-t),t<2+b}}] When I integrate ...
3
votes
1answer
110 views

Solving Piecewise Differential Equation using NDSolve (coupling at BC)

I am having some issues in dealing with a system of differential equations. I would like to solve a 1D diffusive heat equation across several regions with different material properties. I now have a ...
0
votes
1answer
68 views

Plotting a Piecewise function that returns implicit equations using ContourPlot

I am using ContourPlot to plot implicit equations. Plotting separate implicit equations seems to work fine, however I can't get ContourPlot to plot a piecewise function that returns implicit equations....
1
vote
2answers
62 views

Obtaining the diagonal of Jacobians inside a piecewise function

I have a piecewise function that has in each case an N number of functions that take N arguments. I want to retrieve the diagonals of the Jacobian, or simply the element-wise first derivative of the N ...
1
vote
1answer
47 views

Using assumptions, weird output [closed]

I have a Piecewise function, of the type: $Assumptions = b > a > 0 fun[k_] := Piecewise[{{3k, 0<=k<a}, {k^2, a<=k<=b}}] fun[a] When evaluating ...
3
votes
1answer
56 views

Piecewise function inside If statement or another Piecewise function breaks outputs

I have a calculation that outputs a piecewise function that has as its cases a list of expressions. An example (3 cases with each a list of 4 expressions) is below: ...

1
2 3 4 5
8