Questions about the Piecewise function, which is represented by different expressions for different ranges of values of its independent variable.

learn more… | top users | synonyms

-2
votes
1answer
61 views

Manipulate aborts the computation of NDSolve with the Piecewise function after curtain time [on hold]

I'm facing the problem with performance: Manipulate is working fine till end time =60 sec, after that it aborts. There is NDSolve inside Manipulate with Piecewise function, and the plot of the ...
0
votes
1answer
64 views

Piecewise Function, Explanation of Extra Case

Consider: Can someone explain why the 0, True occurs? As a second question, I like to fill the endpoints as follows: ...
3
votes
2answers
71 views

How do I find the intersection points of two piecewise functions? [closed]

I've got a piecewise function that is defined as follows: ...
3
votes
2answers
99 views

Plot a parametric function from $\mathbb{R}^2$ to $\mathbb{R}^2$

I want to plot the following function defined on $[-1,1]\times[-1,1]\setminus(0,0)$: $$ F(x,y,t)= \begin{cases} (1-t)(x,y)+t(1,\frac{y}{x})& \text{if}\ -x\leq y\leq x \\ ...
0
votes
2answers
30 views

Plot Piecewise does not work with NDSolve, works with ordinary function [closed]

How to join output from NDSolve with another function in a plot, using Piecewise or something else? I could join a simple function with another in a plot, but could not do it for the output. MWE: ...
0
votes
2answers
60 views

If Which Piecewise-defined function [closed]

How would I write a function using If and/or Which command for following Piecewise-defined function then plot the function ...
4
votes
2answers
103 views

Derivative of piecewise function

I tried to find $f'(0)$ of this function: $$f(x) = \begin{cases} x\cdot\sin(\frac{1}{x}) & \text{if $x\ne0$} \\ 0 & \text{if $x=0$} \end{cases}$$ This is what I tried in Mathematica: ...
0
votes
0answers
39 views
-1
votes
1answer
69 views

Make plot of parametric function with piecewise components

How can I plot this curve in Mathematica $x(t)=\begin {cases} 2 (t-n+1) \: , \: t\in [n-1,n-1/2] \\ 2-2 (t-n+1) \: , \: t\in [n-1/2, n] \end {cases}$ $y(t)=\begin {cases} 2 (\sqrt {2}t-n+1) \: , ...
2
votes
1answer
70 views

NDSolve with piecewise function gives error “Encountered non-numerical value for a derivative at x == 0.” [duplicate]

I am solving differential equation with piecewise function and i am getting error that NDSolve::ndnum: Encountered non-numerical value for a derivative at x == 0.. ...
2
votes
0answers
41 views

Why does this form of piecewise function cause a general stop message? [closed]

I am currently learning about Mathematica by reading the book Mathematica by Example, 4th Edition. In that book, a piecewise function was defined as follows: ...
1
vote
0answers
30 views

Piecewise in 2D with quadrants as conditions

I am trying to define a piecewise vector field. Can the condition be of the form I am using (i.e. a quadrant)? I can't also make Piecewise work with more than two ...
2
votes
1answer
56 views

NDSolve Dankwerts boundary conditions with changing discrete variable

I'm modeling a advection-diffusion-reaction plug flow reactor (2nd order ODE) at steady state: $$0=-v \frac{\delta p[z]}{\delta z}+D\frac{\delta ^2 p[z]}{\delta z^2}-k p[z]$$ With Dankwerts boundary ...
13
votes
3answers
222 views

Piecewise imposes internal boundaries in NDSolve - is this expected?

In the following code I used True as the predicate for DirichletCondition and found that the boundary condition was applied not ...
5
votes
4answers
202 views

Recursive piecewise integral relation with piecewise base case?

How is this recursive formula $$ f_{n+1}(z) = \int_0^1 f_{n}(z-y)\,{\rm d}y $$ implemented in Mathematica? The base case is $$ f_1(z) = \begin{cases} 1 & 0\leq z\leq 1 \\ 0 & ...
4
votes
1answer
116 views

Integration of a piecewise function

Define f[x_, i_] := Piecewise[{{1/n, 0 < x < (i - 1)/n}, {(i/n - x), (i - 1)/n < x < i/n} , {0, i/n < x}} ]; I would like to compute ...
2
votes
0answers
50 views

Mathematica Manipulate, Plot, Piecewise [duplicate]

I have two functions h2 and v2 that I need to graph using Piecewise and be able to ...
2
votes
1answer
67 views

About NDSolve with piecewise inputs

I am trying to solve numerically two differential equations with NDSolve. ...
10
votes
1answer
117 views

Plot3D with Piecewise is Empty [duplicate]

I don't understand what has happened here. Please can someone explain? I start by defining a 2D function and plotting a couple of cases ...
1
vote
0answers
30 views

Piecewise function plots weird when given expression with symbol vs writing it explicitly

The only difference is that in the second snippet the expression is written out explicitly. displacement = (Sin[x - Pi/2 - t] + 1)/2 This doesn't work: ...
2
votes
0answers
50 views

Efficiently summing sets of piecewise linear functions

I am doing a type of permutation test on a collection of continuous piecewise linear functions, which I'm representing in Mathematica using Piecewise. Specifically, ...
-2
votes
1answer
86 views

A piecewise function with way too many pieces

I'm currently calculating a periodic square wave current function to feed into a particle accelerator. It's a square wave that ramps up to a certain frequency and then drops back to the base frequency ...
7
votes
0answers
75 views

Bug in PiecewiseExpand and Mod with assumptions

Bug introduced in 9.0 or earlier and persisting through 10.3 The following code using PiecewiseExpandand Modgives the wrong ...
5
votes
0answers
50 views

External and internal Assumptions on `PiecewiseExpand` and `Mod`

After this question I'm intrigued about the different behaviors depending where and how the assumptions are given. ...
1
vote
5answers
139 views

Plotting a hat function

I want to plot a hat function which is zero on [-1,1] except (-0.01,0.01). I have tried: Plot[Piecewise[{{1 - Abs[t], -0.01 < t < 0.01}}, 0], {t, -1, 1}] ...
6
votes
1answer
107 views

Plotting piecewise functions with distinct colors - issue found [duplicate]

I've been making use of the following thread: Plotting piecewise function with distinct colors in each section A handy feature I found there goes as follows: ...
2
votes
1answer
84 views

Problems with multidimensional system of ODEs

I am trying to look at the migration of "i" number of species "c" in "10" number of habitats {designated as "j"} and to study their population size as a function of time "t". I have this following ...
2
votes
3answers
96 views

Extract function from a parametric interpolating function

I've read the answers of How to make use of an interpolating function outside of Mathematica?, Interpreting the interpolating function and saving data to plot with external program, Extracting the ...
1
vote
2answers
114 views

Piecewise Integration

I am trying to integrate a piecewise defined function twice. It represents the acceleration of a projectile. I am obtaining it's position as a function of time if it starts from rest at the ground, ...
4
votes
2answers
85 views

Create List of Functions using Piecewise

It sometimes is useful to combine such expressions as z1[t_] = Piecewise[{{Sin[t], Sin[t] > Cos[t]}}] z2[t_] = Piecewise[{{Cos[t], Sin[t] > Cos[t]}}] into ...
6
votes
1answer
61 views

Troubles using Which or Piecewise to define a function

I have a very simple task, but for some reason I fail to accomplish it. I want to use Which to define a function. I think the code is self-explanatory: ...
0
votes
1answer
137 views

Using Plot and Piecewise to graph a roller coaster

I am graphing a roller coaster using Piecewise and Plot commands on Mathematica. I have the first 2 Piecewise functions and would like to add a loop to the end of it. Here is my initial graph: This ...
0
votes
1answer
67 views

ParametricPlot and Piecewise function

I want to create a ParametricPlot with multiple Piecewise functions in it. I have tried the following code but it doesn't work ...
0
votes
0answers
49 views

Get Domain resp. implicit piecewise definition of numeric Function

Given the following quintic polynomial ...
0
votes
0answers
73 views

Piecewise NDSolveValue: Nested Variable Iteration

I am attempting to make the variable Rc a piecewise-function of [z] and have it update as NDsolve iterates through the range of 'z' such as {z,0,Le), but to no avail. The following code is an attempt ...
3
votes
0answers
30 views

How to get a list of discontinuous points from a piecewise function [duplicate]

I want to find a list of discontinuous points from a piecewise function. Suppose I have a function ...
7
votes
3answers
294 views

How to efficiently get breakpoints of piecewise functions

Setting. Imagine that we have several arbitrary linear functions in 2D that can be changed manually (say, slopes are parameters). Their Min (or ...
0
votes
0answers
41 views

Working with Piecewise functions - Hexsplines

I'm trying to use the convolution definition of hexsplines, that is, a hexspline is the convolution of the indicator function of a hexagon (of sidelength 1 and centre $(0,0)$ ) with itself. I'm ...
2
votes
2answers
131 views

Piecewise function with integer conditions

I'm trying to define (and plot) a piecewise function with the following structure: $$f(x) = \begin{cases} g(x) & nT \leq x \leq \frac{2n+1}{2}T\\ -g(x) & \frac{2n+1}{2}T ...
5
votes
1answer
105 views

How to sort the ranges of a Piecewise expression?

I have the following PieceWise expression ...
3
votes
0answers
76 views

Inverse of piecewise function with pieces invertible on specific domain

I have piecewise continuous function defined below: f=Piecewise[{ {15 + 1/6*(# - 3), # <= 27}, {# - 12 + 4 * Exp[-5/24*(#-27)], 27 < #} }]; This ...
0
votes
1answer
103 views

How to enter piecewise functions into Mathematica [closed]

I'm trying to enter a piecewise function (named eq30) into Mathematica. However, it seems not to work. The expression I entered is ...
-2
votes
1answer
41 views

NIntegrate a function containing NDSolve

I am having an issue integrating a function for which I am getting values for when I evaluate it. ...
0
votes
1answer
95 views

DSolve with piecewise coefficeints wrong, why?

sorry if this is a duplicate (I am pretty sure) but I was not able to find the question. I am playing around with DSolve with variable coefficients. In the documentation it is said, that DSolve can ...
1
vote
1answer
172 views

Piecewise Function within NDSolve

So I am quite new to Mathematica and programming in general and I am running into an issue while trying to use the numerical diff eq solver (NDSolve) within mathematica. This is what my code looks ...
1
vote
2answers
104 views

Derivative of Continuous and Differentiable Piecewise function is indeterminate

I'm attempting to analytically stitch together two linear functions with two quadratic functions. The function I'm considering, then, is a piecewise function consisting of 4 parts. Below are the ...
1
vote
0answers
91 views

Maximize and NMaximize don't work for my function

I defined the following function: d1[x_] := Min[Abs[FractionalPart[x]], 1 - Abs[FractionalPart[x]]] and tried to evaluate the following function: ...
0
votes
1answer
45 views

Cannot determine, what this partw error message is aiming at …

So i am trying to plot the magnetic vector field surrounding a "flat conducting cable" (don't know the proper english expression). This is the "code" (there are some constants in the analytic ...
2
votes
1answer
201 views

How I can make the StreamPlot of this differential equation?

I need the StreamPlot of this differential equation but I don't know how. dp/dt = 0.4 p(1 - p/30), 0 <= t < 5 and 0.4 p (1 - p/30) - 0.25 p, t > 5
1
vote
3answers
82 views

Fill an array, symmetric with respect to its centre

I want to create an array that must be symmetric with respect to the centre of it, as in the following example: 0 1 2 3 4 3 2 1 but, instead of having such ...