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
1
vote
1answer
36 views

Find the intervals where a piecewise is maximum

I have the following 3 piecewise functions and I would like to have the threshold of the upper envelope. ...
7
votes
1answer
94 views

Converting Piecewise function to C code

I'm trying to convert a function to C Code f = D[Piecewise[{{x^2, -10 < x < 0}, {x, x > 0}}], x] I decided to scan through conditions and corresponding ...
0
votes
1answer
29 views

Extending a piecewise function defined over a limited domain to be periodic over a larger domain

I need to plot the piecewise function $ \qquad f(x) = x^2\quad -2 <= x <= 0, \\ \qquad f(x) = 0\qquad 0 <= x <= 1 \\ \qquad f(x) = 1-x\quad 1 <= x <= 3 \\ $ as a periodic ...
0
votes
1answer
558 views

Fourier Transform plot of a piecewise function

I'm working with financial data. I used "Find Formula" to find an approximate function and then I applied FourierTransform to it. Here are the function and the Fourier Transform: ...
0
votes
1answer
46 views

Piecewise function [closed]

I have the differential equation $$ \omega'(t)= \begin{cases} \frac{1}{J_t}\left(\frac{B}{2}(F_l-F_r)-B_l\omega\right) & \text{if turning=true}\\ 0 & \text{if ...
0
votes
0answers
33 views

Function inverse to PiecewiseExpand

I'm working with very complex piecewise functions which I'd like to decompose into combination of simpler ones. I'm aware of PiecewiseExpand function which does the opposite to what I need. Is there a ...
1
vote
0answers
33 views

How to convert output from Reduce into a piecewise function?

Reduce often provides a much fuller solution than Solve. But it's always in the form of a true statement rather than functions ...
2
votes
2answers
55 views

How to define a discrete distribution with non-integer sample space elements (outcomes)?

How to define a discrete distribution with non-integer states (sample space elements)? I know how to define a discrete distribution with integer states: ...
3
votes
1answer
64 views

elegant definition of piecewise linear functions (spline)

As far as I understand, the Spline object is the result of some approximation or interpolation, it is not for directly defining functions. That's a pity, as that ...
1
vote
1answer
62 views

Piecewise with differential equations

I have the following differential system. The calibration I use is as follows ...
3
votes
1answer
65 views

Piecewise function not evaluating in NDSolve

Perhaps it's something obvious, but why does this simple piecewise function (as well as other conditionals) not evaluate in NDSolve: ...
0
votes
0answers
37 views

Piecewise function to include SawtoothWave function

I am trying to write a Piecewise function that includes the SawtoothWave function. Can someone indicate how to do this, or if it is possible within mathematica? The piecewise code is here: ...
0
votes
1answer
33 views

How does Mathematica solve this 2D piecewise function from constraints?

I am interested in learning the technique(s) used to solve the following 2D piecewise equation for $x, y$ when given $z$, where $z = f(x, y)$. $\text{Given that $x \in \mathbb{Z}$, $y \in \mathbb{Z}$}...
2
votes
2answers
38 views

Piecewise function and deriving - solving

I'm working in a (Economics) problem where I want to add two concave (profit) functions in order to maximize them together through one variable (quantity). My problem is that one of the two functions ...
4
votes
2answers
212 views

Why does plot not show where Piecewise function is not zero?

From my user point view this looks like bug. But I am not an expert. f[x_?NumericQ]:=Piecewise[{{1,x==1},{0,True}}]; Plot[f[x],{x,0,1}] Does not show ...
1
vote
2answers
43 views

Displaying part of piecewise function

If I define a piecewise function f[t_] := Piecewise[{{t^2, t < 0}, {Sin[t], t > 0}}] Which[f[t], t > 0] how do I display only one part of the function? ...
0
votes
0answers
53 views

Is it possible to unmerge Piecewise expressions?

I have an expression involving Piecewise that I want to break into specific cases. If I let Mathematica's simplification rules loose then it doesn't seem to pick up an obvious cancellation which can ...
1
vote
2answers
36 views

RecurrenceTable of a piecewise recurrence function

How to can I get RecurrenceTable to deal with a piecewise function? For example, $ \qquad x_{n+1}= x_n(1.5-0.5x_n)\qquad \text{if $x_n\ge0.5$}\\ \qquad x_{n+1}= ...
0
votes
2answers
30 views

Piecewise vector

I need to have a vector with the length of 15000. The first 4000 elements have value 12, the next 3000 elements, that is 4001 to 7000 be 0 and the rest of it to the last be 5. I have written it with ...
0
votes
1answer
55 views

Returning a string from a piecewise function

I need to define a function that behaves as a piecewise function, but will return a string instead of a value. Part of the function that I have written is provided below. The full function continues ...
2
votes
2answers
136 views

Defining a piecewise function with underlying lattice

I'm fairly new to Mathematica, and programming in general, but I'm trying to define an $n$-dimensional piecewise function, $F({\bf x})$. Properties of the function are set by an underlying lattice, ...
22
votes
5answers
5k views

Extracting the function from InterpolatingFunction object

I've used Interpolation[] to generate an InterpolatingFunction object from a list of integers. ...
4
votes
2answers
157 views

Heat equation with variable conductivity

Let us consider the (very simple) problem $\qquad \partial_x[k(x)\,\partial_xu]=0,\quad x\in [0,1]$ $\qquad u(0)=0,\ u(1)=1,$ with $l\in(0,1)$ $\qquad k(x)=\left\{\begin{array}{l}k_1^{},x<l\\k_2^...
3
votes
3answers
989 views

Why does the first derivative of a piecewise continuous function have discontinuities?

I have this piecewise continuous function which is also continuously differentiable over time : ...
0
votes
3answers
213 views

Using Solve to obtain a constant so that f(x) is continuous at x=2

I need to solve for c such that the function is continuous at x=2. How do I do this automatically? I have expressions for the ...
2
votes
0answers
48 views

Make Mathematica evaluate an integral symbolically

The following integral has a symbolic solution, which MMA does not return. $\kappa(x) \begin{cases} \text{mod}(x,1)\le0.5: & 1\\ \text{mod}(x,1)>0.5: & 0 \end{cases}$ $f(z)=\int_0^1 \...
6
votes
2answers
1k views

Piecewise differential equation

Say I have a very trivial function $$ V\left(r\right)=\begin{cases} -V_{0} & 0\leq r\leq R\\ 0 & r>R \end{cases} $$ with $V_{0}>0$ and $R>0$. I would like to let Mathematica solve ...
0
votes
2answers
173 views

Fourier series of an arbitrary periodic piecewise function

Let's take a switch function as an example: $ u(t)= \begin{cases} 1, & \text{$0<t<dT_s$} \\ 0, & \text{$dT_s<t<T_s$} \end{cases} $ How can I get Fourier series of it in ...
1
vote
0answers
55 views

Piecewise function inside Integrate - Wrong result

I tried to evaluate the following integral: ...
1
vote
1answer
117 views

Inaccuracy of Piecewise function? [duplicate]

I have the following issue and can't find a solution so far. ...
2
votes
1answer
80 views

Fast and Listable Piecewise function

I am writing a simulation where I have an array with ten columns and on the order of millions of rows, for which I need to iterate on the order of ten thousand times, making computation time a major ...
4
votes
2answers
64 views

How can I make a NumberLineLogPlot'?

I have a piecewise function that is defined in logarithmic intervals, i.e., the different pieces are defined on ...
0
votes
0answers
34 views

Imposing conditions on argument for a function definition

Suppose that I wish to use "Piecewise" to merge two different interpolating functions (obtained via a NDSolve of some ODE), defined over negative and positive arguments respectively, like: ...
0
votes
1answer
59 views

Defining a function with a point of finite discontinuity [closed]

I wrote the code for the function $T$ defined on $[0,1]$ by $T(x)=\frac{x+2}{3}$ if $x\neq\frac{1}{2}$ and $T(\frac{1}{2})=1$ as follows. ...
1
vote
1answer
55 views

Integrating piecewise function in two variables

I want to find (and plot) the integral of a 'smooth' version of the Möbius function MoebiusMu[x]: ...
3
votes
4answers
245 views

Continuous non-piecewise equivalent of smoothstep function?

I have a smooth step function given by the piecewise function ...
2
votes
0answers
83 views

Slow Plotting of a Piecewise Function

I have stumbled upon an issue that seems very weird to me. I have two Piecewise functions that describe exactly the same curve. The only difference between them is that the first function has two ...
0
votes
1answer
82 views

Convert a piecewise definition of a single impulse into an impulse train

NOTE: See update at end of question I have a function smoothstep (based on the derivative of a smoothstep function) that gives a single impulse as follows: ...
6
votes
2answers
442 views

Solving Stefan's solidification problem - for the case of 3 regions

This question heavily related to this question, where the case of two PDE's are solved along with a zipping condition that is a function of time. Using the link in the code I have solved this set of ...
0
votes
1answer
131 views

How to change colors of 3D parametric plot

I have a 3D iterative plot, where each iteration (1,2,3) is represented by equation of piecewise linear function. I am trying to change the colors of plot, to get for every iteration (piecewise ...
0
votes
2answers
77 views

How to plot 3D discontinuous iterative plot?

I am having troubles with plotting this set of data triples={{0, 1, 1}, {9/50, 4/5, 1}}, {{9/50, 4/5, 1}, {3/8, 4/5, 1}}, {{3/8, 58333/100000, 1}, {3/4, 16667/100000, 1}}, {{3/4, 0, 1}, {1, 0, ...
0
votes
2answers
71 views

how to get coordinates from a plot of piecewise function?

I am having troubles with finding points from a plot. I have a piecewise linear function given by following inequalities. These inequalities I got from previous calculations where I split two ...
0
votes
0answers
24 views

Locating the interval on a piecewise function and integration :

I'm recently learning Mathematica to help me compute some difficult stuff, and let's say I have a piecewise-defined real valued function with a finite number of subpieces. I can index the intervals ...
0
votes
0answers
49 views

How to extract envelope for piecewise defined function? [duplicate]

I have a plot generated from an ugly and complex set of piece-wise functions. I'm looking to extract the envelope function from this data set. I've tried a lot of suggestions in other threads, but ...
0
votes
1answer
62 views

Using Piecewise to plot a defined function [closed]

I'm trying to Plot this function: Between the interval -0.2 < t < 0.1 but it doesn't work. All i get is a blank graph between my intervals. If you could help me out I'd greatly appreciate it. ...
2
votes
1answer
40 views

How to read information from a piecewise function?

I defined a periodic piece wise function y[x_] with some discrete steps with Piecewise command and two lists ...
2
votes
3answers
501 views

Solve piecewise function

I have two piecewise function ...
2
votes
2answers
61 views

Combine `EvenQ` and `Clip` to create a series of pulses

I have a function that produces a single impulse spanning the range [-1,1]: func1 = Cos[Pi*(Clip[x]/2)]^2 I want to create a ...
0
votes
0answers
56 views

Using table and piecewise function together

I am trying to define an equation set, in which the function is very similar to a square wave, but instead, it is defined piecewise at each interval. Now I need to evaluate the equation at each ...
1
vote
1answer
100 views