Chapterبەش 3 · Lectureوانە 3.4
Piecewise Functions: Absolute Value, Floor and Ceilingنەخشە ڕێسا پەلدارەکان: نرخی ڕووت، نەخشەی گەورەترین ژمارەی تەواو و نەخشەی بچووکترین ژمارەی تەواو
Functions that use different formulas on different parts of their domain: the absolute value, the floor and the ceiling , with all the course examples, their step graphs and how programs use them.
کە لە بەشە جیاوازەکانی فۆرمولەی جیاواز بەکار دەهێنن: ، و ، لەگەڵ هەموو نموونەکانی خولەکە، هێڵکارییە پلیکانەییەکانیان و چۆنیەتی بەکارهێنانیان لە .
What you will learnچی فێر دەبیت
- Evaluate and draw a piecewise function, using filled and open dots correctly.
- Write the absolute value as a piecewise function and give its domain and range.
- Compute floors and ceilings, also of negative numbers, and draw their step graphs.
- Use floor and ceiling in everyday counting problems and recognise them in Python.
- بەهای بدۆزەرەوە و بیکێشە، بە بەکارهێنانی ڕاستی خاڵی پڕکراو و کراوە.
- وەک بنووسە و و بدە.
- و بژمێرە، تەنانەت بۆ و هێڵکارییە پلیکانەییەکانیان بکێشە.
- بەرەو خوار و بەرەو سەر لە کێشەی ژماردنی ڕۆژانەدا بەکار بهێنە و لە Pythonـدا بیناسەوە.
One function, several formulasیەک نەخشە، چەند فۆرمولەیەک
Sometimes one formula is not enough to describe a function. A piecewise-defined function uses different formulas on different parts of its domain; each formula comes with a condition that says where it applies.
هەندێک جار یەک فۆرمولە بەس نییە بۆ وەسفکردنی . لە بەشە جیاوازەکانی فۆرمولەی جیاواز بەکار دەهێنێت؛ لەگەڵ هەر فۆرمولەیەک مەرجێک هەیە کە دەڵێت لە کوێ جێبەجێ دەکرێت.
A walnut seller charges 12,000 dinars per kilogram for less than 1 kg, but only 10,000 dinars per kilogram if you buy 1 kg or more. The price for w kilograms is one function with two formulas: when , and when . So 0.8 kg costs 9,600 dinars and 1.5 kg costs 15,000 dinars.
گوێزفرۆشێک بۆ کەمتر لە 1 کیلۆ، کیلۆی بە 12,000 دینار دەفرۆشێت، بەڵام ئەگەر 1 کیلۆ یان زیاتر بکڕیت کیلۆی بە 10,000 دینار. نرخی w کیلۆ یەک بە دوو فۆرمولە: کاتێک و کاتێک . کەواتە 0.8 کیلۆ 9,600 دینار و 1.5 کیلۆ 15,000 دینار تێدەچێت.
Where the analogy stops workingسنووری ئەم نموونەیە
In a real bazaar you can bargain. A piecewise function decides the boundary exactly: exactly 1 kg uses the second price, because the condition is .
لە بازاڕی ڕاستەقینەدا دەتوانیت مامەڵە بکەیت. سنوورەکە بە وردی دیاری دەکات: ڕێک 1 کیلۆ نرخی دووەم وەردەگرێت، چونکە مەرجەکە ـە.
The conditions must fit together so that every x of the domain gets exactly one output: usually they do not overlap, and together they cover the whole domain. If two conditions both included the same x and gave different values, the rule would not be a function (What is a function?).
مەرجەکان دەبێت وا لەگەڵ یەک بگونجێن کە هەر xـێکی تەنها یەک وەربگرێت: زۆرجار یەکتر داناپۆشن و پێکەوە هەموو دەگرنەوە. ئەگەر دوو مەرج هەمان xـیان بگرتایەتەوە و دوو بەهای جیاوازیان بدایە، یاساکە نەدەبوو (نەخشە چییە؟).
One function, several formulasیەک نەخشە، چەند فۆرمولەیەک
Evaluating and drawing a piecewise functionدۆزینەوەی بەها و کێشانی نەخشەیەکی ڕێسا پەلدار
A function with two pieces: the first formula for , the second for .
بە دوو پارچە: فۆرمولەی یەکەم بۆ و فۆرمولەی دووەم بۆ .
- Find the right pieceپارچە ڕاستەکە بدۆزەرەوە
Check which condition the input satisfies. For : , so the first piece applies.
بپشکنە کام مەرج پڕ دەکاتەوە. بۆ : ، بۆیە پارچەی یەکەم جێبەجێ دەبێت.
- Use only that formulaتەنها ئەو فۆرمولەیە بەکار بهێنە
. In the same way (because ) and .
. بە هەمان شێوە (چونکە ) و .
To draw it, draw each piece only on its own part of the domain. At a boundary, a filled dot means the point belongs to the graph and an open dot means it does not. At the second piece is used, so is filled, while , where the first piece would end, is open.
بۆ کێشانی، هەر پارچەیەک تەنها لەسەر بەشی خۆی لە بکێشە. لە سنووردا، خاڵی پڕکراو واتە خاڵەکە سەر بە هێڵکارییەکەیە و خاڵی کراوە واتە نییە. لە ـدا پارچەی دووەم بەکار دێت، بۆیە پڕکراوە، بەڵام ، کە پارچەی یەکەم لێی کۆتایی دێت، کراوەیە.
Graphs a piecewise function one piece at a time with small tables, explains open and filled dots, then reads the domain and range.
پارچە بە پارچە بە خشتەی بچووک دەکێشێت، خاڵی کراوە و پڕکراو ڕوون دەکاتەوە، پاشان و دەخوێنێتەوە.
Whole video (6:43): three pieces drawn on their own parts of the domain; open dot = not included, filled dot = included.
هەموو ڤیدیۆکە (6:43): سێ پارچە، هەر یەکەیان لەسەر بەشی خۆی لە دەکێشرێت؛ خاڵی کراوە = تێدا نییە، خاڵی پڕکراو = تێدایە.
The absolute value as a piecewise functionنرخی ڕووت وەک نەخشەیەکی ڕێسا پەلدار
The first piecewise function in the notes is the absolute value:
یەکەم لە تێبینییەکاندا :
Why for negative numbers? Because the minus sign turns a negative number into a positive one: . For the others nothing changes: , . The meaning of as the distance from 0 is taught in Absolute value.
بۆچی بۆ ؟ چونکە نیشانەی سالب دەکات بە : . بۆ ئەوانی تر هیچ ناگۆڕێت: ، . واتای وەک دووری لە 0ـەوە لە نرخی ڕووت دەخوێنرێت.
Every real number has an absolute value, so . The output is never negative and every is reached (by ), so .
هەموو هەیە، بۆیە . هەرگیز سالب نییە و هەموو بەدەست دێت (بە )، بۆیە .
In Sorani: rewrite sums of absolute values, such as |x|+|x-2|, as piecewise functions, using a number line to choose the sign of each bar.
بە سۆرانی: کۆی ، وەک ، دەکاتە ؛ بە هێمای ناو هەر دیاری دەکات.
Sorani (8:33), harder examples than this screen: |x| + |x - 2| and |x + 1| - |x - 2| rewritten as three-piece functions with a sign chart; each bar becomes + or - on each region.
بە سۆرانی (8:33)، نموونەی قورستر لەم شاشەیە: و وەک سێپارچەیی بە دەنووسرێنەوە؛ لە هەر ناوچەیەکدا هەر دەبێتە + یان −.
The floor function نەخشەی گەورەترین ژمارەی تەواو
The greatest integer function, also called the integer floor function, gives for every number x the greatest integer that is less than or equal to x. It is written ; some books write or . On the number line: if x is an integer, stay where you are; otherwise walk left to the nearest integer.
، کە پێی دەوترێت greatest integer function یان integer floor function، بۆ هەر ژمارەیەکی x گەورەترین دەدات کە لە x بچووکترە یان یەکسانە. بە دەنووسرێت؛ هەندێک کتێب یان دەنووسن. لەسەر : ئەگەر x بێت، لە شوێنی خۆت بمێنەوە؛ ئەگەر نا، بەرەو چەپ بڕۆ بۆ نزیکترین .
| Becauseچونکە | ||
|---|---|---|
| 0 is already an integer0 خۆی | ||
| 2 is already an integer2 خۆی | ||
| is already an integer خۆی |
In Sorani: the floor function, its symbols [x], ⟦x⟧ and ⌊x⌋, and how to find it for whole numbers and for positive and negative decimals.
بە سۆرانی: و هێماکانی ، و ، هەروەها دۆزینەوەی بۆ و بۆ ژمارەی دەیی موجەب و سالب.
Sorani segment 2:30-11:25: the symbols [x], ⟦x⟧, ⌊x⌋ for the floor ("نەخشەی فلۆر") and how to find it for whole numbers and for positive and negative decimals.
بەشێکی سۆرانی، لە 2:30 تا 11:25: هێماکانی ، و بۆ (لە ڤیدیۆکەدا « فلۆر»)، هەروەها دۆزینەوەی بۆ و بۆ ژمارەی دەیی موجەب و سالب.
The floor function نەخشەی گەورەترین ژمارەی تەواو
The graph of the floor functionهێڵکاریی نەخشەی
For every x with (n an integer) the floor is n. So the graph is a horizontal segment at height n over each interval : a filled dot on the left end ( belongs to this step) and an open dot on the right end ( already belongs to the next step). Written as a piecewise function with infinitely many pieces:
بۆ هەر xـێک کە (n )، . بۆیە هێڵکارییەکە لەسەر هەر پارچە هێڵێکی ئاسۆییە بە بەرزیی n: خاڵی پڕکراو لە لای چەپ ( سەر بەم پلەیەیە) و خاڵی کراوە لە لای ڕاست ( سەر بە پلەی دواترە). وەک بە ژمارەیەکی بێکۆتا پارچە:
Every real number has a floor, so ; the outputs are exactly the integers, so . A function whose graph looks like stairs is called a step function.
بۆ هەموو هەیە، بۆیە ؛ ڕێک ، بۆیە . کە وەک پلیکانە بێت پێی دەوترێت .
The ceiling function نەخشەی بچووکترین ژمارەی تەواو
The least integer function, also called the integer ceiling function, gives for every x the smallest integer that is greater than or equal to x. It is written . On the number line: an integer stays; any other number walks right to the nearest integer.
، کە پێی دەوترێت least integer function یان integer ceiling function، بۆ هەر xـێک بچووکترین دەدات کە لە x گەورەترە یان یەکسانە. بە دەنووسرێت. لەسەر : لە شوێنی خۆی دەمێنێتەوە؛ هەر ژمارەیەکی تر بەرەو ڕاست دەڕوات بۆ نزیکترین .
The ceiling function نەخشەی بچووکترین ژمارەی تەواو
The graph of the ceiling functionهێڵکاریی نەخشەی
For every x with the ceiling is n. So each step sits over , with an open dot on the left and a filled dot on the right, the opposite of the floor graph.
بۆ هەر xـێک کە ، . بۆیە هەر پلەیەک لەسەر ـە، بە خاڵی کراوە لە چەپ و خاڵی پڕکراو لە ڕاست، بە پێچەوانەی .
Floor and ceiling side by side و پێکەوە
Watch the blue ring slide along the x-axis. The floor value (orange) stays the same until x reaches the next integer, then jumps up by 1; the ceiling value is always the integer just above, unless x itself is an integer.
سەیری بازنە شینەکە بکە کە بە درێژایی x دەخزێت. بەهای (پرتەقاڵی) وەک خۆی دەمێنێتەوە تا x دەگاتە دواتر، پاشان 1 بەرز دەبێتەوە؛ بەهای هەمیشە ئەو کە ڕێک لە سەرەوەیە، مەگەر x خۆی بێت.

- For an integer n: .
- For any x that is not an integer: .
- Always and .
- A minus sign swaps them: ; for example .
- بۆ n: .
- بۆ هەر xـێک کە نەبێت: .
- هەمیشە و .
- نیشانەی سالب جێیان دەگۆڕێتەوە: ؛ بۆ نموونە .
Floor and ceiling in programs و لە بەرنامەکاندا
Programmers meet floor and ceiling all the time: how many full boxes, how many pages, how many rows. A search shows 47 results, 10 per page. It needs pages, and only of them are full.
بەرنامەسازەکان بەردەوام پێویستیان بە بەرەو خوار و بەرەو سەر دەبێت: چەند سندوقی پڕ، چەند لاپەڕە، چەند ڕیز. گەڕانێک 47 ئەنجام پیشان دەدات، 10 دانە لە هەر لاپەڕەیەکدا. پێویستی بە لاپەڕە هەیە و تەنها لەوانە پڕن.
Common mistakesهەڵە باوەکان
| Mistakeهەڵە | What is trueڕاستییەکە |
|---|---|
| ": just drop the decimals."«: تەنها بەشی دەیی فڕێ بدە.» | Floor goes left on the number line: . لەسەر بەرەو چەپ دەڕوات: . |
| Filled and open dots swapped on the floor graph.گۆڕینەوەی خاڵی پڕکراو و کراوە لە ـدا. | Floor: filled on the left of each step; ceiling: filled on the right.: لە چەپی هەر پلەیەک پڕکراو؛ : لە ڕاست پڕکراو. |
| "The range of the floor function is ."« ، ـە.» | Only integers come out: the range is .تەنها دێنە دەرەوە: ـە. |
| " for every x."«بۆ هەموو xـێک .» | Only for ; for use .تەنها بۆ ؛ بۆ بەکار بهێنە. |
| Two pieces whose conditions overlap and give different values.دوو پارچە کە مەرجەکانیان یەکتر دادەپۆشن و بەهای جیاواز دەدەن. | Then one x has two outputs: not a function. Make the conditions fit together.ئەو کاتە یەک x دوو دەبێت: نییە. مەرجەکان وا دابنێ کە لەگەڵ یەک بگونجێن. |
Using int() in Python as the floor.بەکارهێنانی int() لە Pythonـدا بۆ دۆزینەوەی . | int(-3.5) is −3, but ; use math.floor or //.int(-3.5) دەکاتە ، بەڵام ؛ math.floor یان // بەکار بهێنە. |
Exercisesڕاهێنانەکان
Let if , if , and if . Find , , , and .
با بێت ئەگەر ، ئەگەر و ئەگەر . ، ، ، و بدۆزەرەوە.
Hintئاماژە
First decide which condition each input satisfies.
سەرەتا بڕیار بدە هەر کام مەرج پڕ دەکاتەوە.
Show answerوەڵامەکە پیشان بدە
Write as a piecewise function and check it at , and .
وەک بنووسە و لە ، و ـدا بیپشکنە.
Show answerوەڵامەکە پیشان بدە
Replace x by in the definition of : the inside is exactly when . Check: , , .
لە پێناسەی ـدا x بە بگۆڕە: ناوەوەکەی، ، ڕێک کاتێک ـە کە . پشکنین: ، ، .
Find , , , , and .
، ، ، ، و بدۆزەرەوە.
Show answerوەڵامەکە پیشان بدە
(); (walk right from −3.14); (an integer); (just above 4 is enough); ; .
()؛ (لە ـەوە بەرەو ڕاست بڕۆ)؛ ()؛ (کەمێک لە سەرووی 4 بەسە)؛ ؛ .
Find all x with (a) and (b) . Write each answer as an interval.
هەموو ئەو xـانە بدۆزەرەوە کە (أ) و (ب) . هەر وەڵامێک وەک بنووسە.
Show answerوەڵامەکە پیشان بدە
(a) , the half-open interval : 2 itself gives 2, but 3 already gives 3. (b) , the interval : , but anything just above 1 up to 2 gives 2.
(أ) ، : 2 خۆی 2 دەدات، بەڵام 3 ئیتر 3 دەدات. (ب) ، : ، بەڵام هەر ژمارەیەک کەمێک لە سەرووی 1ـەوە تا 2 دەبێتە 2.
A car park charges 1,000 dinars for every started hour. Write the cost for t hours () with floor or ceiling, and find the cost for 7.5 hours and for exactly 3 hours.
شوێنێکی ڕاگرتنی ئۆتۆمبێل بۆ هەر کاتژمێرێکی دەستپێکراو 1,000 دینار وەردەگرێت. تێچووی t کاتژمێر () بە یان بنووسە و تێچووی 7.5 کاتژمێر و ڕێک 3 کاتژمێر بدۆزەرەوە.
Show answerوەڵامەکە پیشان بدە
A started hour counts as a whole hour, so we round up. Exactly 3 hours is not rounded, because .
کاتژمێرێکی دەستپێکراو وەک کاتژمێرێکی تەواو دەژمێردرێت، بۆیە بەرەو سەر نزیکی دەکەینەوە. ڕێک 3 کاتژمێر نزیک ناکرێتەوە، چونکە .
Exercisesڕاهێنانەکان
Exercises 6–8: graphs with dots and jumpsڕاهێنانەکانی 6–8: هێڵکاری بە خاڵ و بازدانەوە
A student defines the function below and fills a table: , , , , . What happens at ? Is f a function? Fix it, then compare with g.
خوێندکارێک f و g وەک خوارەوە پێناسە دەکات و بۆ f خشتەیەک پڕ دەکاتەوە: ، ، ، ، . لە ـدا چی ڕوو دەدات؟ ئایا f ؟ چاکی بکەرەوە، پاشان لەگەڵ g بەراوردی بکە.
Hintئاماژە
Check which conditions satisfies.
بپشکنە کام مەرجانە پڕ دەکاتەوە.
Show answerوەڵامەکە پیشان بدە
At two conditions hold, and , and they give two outputs, and 4. One input with two outputs: as written, f is not a function. Fix: use for the last piece. Then , and the graph jumps from the filled dot to the open dot .
لە ـدا هەردوو مەرجی و ڕاستن و دوو دەدەن: و 4. یەک بە دوو : وەک نووسراوە، f نییە. چاککردنەوە: بۆ پارچەی کۆتایی بەکار بهێنە. ئەو کاتە و هێڵکارییەکە لە خاڵی پڕکراوی ـەوە باز دەدات بۆ خاڵی کراوەی .
In g the conditions also overlap, at , but both pieces give the same output, and 4. So g is a function, and its graph has no jump at 2: , , , , . Still, write for the last piece so that the conditions do not overlap.
لە gـدا مەرجەکان دیسان یەکتر دادەپۆشن، لە ـدا، بەڵام هەردوو پارچەکە هەمان دەدەن: و 4. کەواتە g و هێڵکارییەکەی لە 2ـدا باز نادات: ، ، ، ، . لەگەڵ ئەوەشدا بۆ پارچەی کۆتایی بنووسە بۆ ئەوەی مەرجەکان یەکتر دانەپۆشن.
Let for and . Find , and , sketch h, and give its domain and range.
با بێت بۆ و . ، و بدۆزەرەوە، h بکێشە و و بنووسە.
Show answerوەڵامەکە پیشان بدە
, , . The graph is the parabola with a hole (open dot) at , plus one filled dot at . Domain: . Range: . The hole does not remove 4 from the range, because ; and 7 was there anyway, at .
، ، . هێڵکارییەکە ـە بە کونێک (خاڵێکی کراوە) لە ، لەگەڵ یەک خاڵی پڕکراو لە . : . : . کونەکە 4 لە دەرناکات، چونکە ؛ 7ـیش هەر لەوێ بوو، لە .
Sketch for , for and for . Give its range and say in words what it does to a number.
بۆ ، بۆ و بۆ بکێشە. بنووسە و بە وشە بڵێ چی بە ژمارەیەک دەکات.
Show answerوەڵامەکە پیشان بدە
Flat at on the left, the line in the middle, flat at 5 on the right. The pieces meet at and , so there is no jump. Range: . It clamps a number into the interval : numbers inside stay the same, numbers outside are pushed to the nearest end: , , .
لە چەپ لە ـدا تەختە، لە ناوەڕاست هێڵی ـە و لە ڕاست لە 5ـدا تەختە. پارچەکان لە و ـدا بە یەک دەگەن، بۆیە هیچ بازدانێک نییە. : . ژمارەیەک لە ناو ـدا گیر دەکات: ژمارەکانی ناوەوە وەک خۆیان دەمێننەوە و ژمارەکانی دەرەوە دەبرێنە نزیکترین سەر: ، ، .
In computing: programs clamp values all the time: a volume slider stays between 0 and 100, a game character stays inside the screen. In Python the clamp is one line with the built-in min() and max():
لە کۆمپیوتەردا: بەردەوام بەهاکان بەم شێوەیە گیر دەکەن: دەنگی ئامێرێک لە نێوان 0 و 100دا دەمێنێتەوە و کارەکتەرێکی یاری لە ناو شاشەکەدا دەمێنێتەوە. لە Pythonـدا گیرکردن یەک دێڕە بە min() و max()ـی ناوخۆیی:
def clamp(x, low=-5, high=5):
return min(max(x, low), high)
print(clamp(-8), clamp(3), clamp(12))
print(clamp(250, 0, 100)) # a volume slider stays between 0 and 100-5 3 5 100
Summaryکورتە
- A piecewise function uses different formulas on different parts of its domain; find the right piece first, and draw each piece only on its part (filled dot = included, open dot = not).
- for and for ; , .
- Floor : the greatest integer (walk left). Ceiling : the smallest integer (walk right).
- Both are step functions with and ; floor steps are filled on the left, ceiling steps on the right.
- In Python:
math.floor,math.ceiland//;int()cuts towards 0.
- لە بەشە جیاوازەکانی فۆرمولەی جیاواز بەکار دەهێنێت؛ سەرەتا پارچە ڕاستەکە بدۆزەرەوە و هەر پارچەیەک تەنها لەسەر بەشی خۆی بکێشە (خاڵی پڕکراو = دەیگرێتەوە، خاڵی کراوە = نایگرێتەوە).
- بۆ و بۆ ؛ ، .
- : گەورەترین کە بێت (بەرەو چەپ). : بچووکترین کە بێت (بەرەو ڕاست).
- هەردووکیان بە و ؛ پلەکانی لە چەپ پڕکراون و هی لە ڕاست.
- لە Pythonـدا:
math.floor،math.ceilو//؛int()بەرەو 0 دەبڕێت.
What is , and what is ? چەندە و چەندە؟
and .
و .
When are the floor and the ceiling of x equal?کەی و یەکسانن؟
Exactly when x is an integer.
ڕێک کاتێک x بێت.
Why is called piecewise?بۆچی پێی دەوترێت نەخشەی ڕێسا پەلدار؟
Because it uses the formula x for and the formula for .
چونکە بۆ فۆرمولەی x و بۆ فۆرمولەی بەکار دەهێنێت.
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
Equal, Constant, One-to-One and Onto Functionsنەخشەی یەکسان، نەخشەی نەگۆڕ، نەخشەی یەک بۆ یەک و نەخشەی گشتگر
Related lecturesوانە پەیوەندیدارەکان
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- OpenStax Calculus Volume 1, 1.2 Basic Classes of Functions (piecewise-defined functions)
- Wikipedia: Floor and ceiling functions (definitions, notation history, properties)
- Python documentation: math — math.floor, math.ceil, math.trunc
- Python language reference: Binary arithmetic operations (floor division //)
- Python documentation: Built-in functions max() and min()
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.