Skip to main content
Tweeted twitter.com/StackMma/status/1486307965175013376
edited tags
Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
edited title
Link
xinxin guo
  • 1.5k
  • 11
  • 13

How to express anya periodic piecewise linear function in terms of Mod function? or linear combination of Mod?

added 14 characters in body; edited title
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13

I am programming a small game (with other programming language) in which I have to use Mod function to express piecewise linear period functions.

In my case, two hard parts I think exist.

(1) The periodic function is linear in the piecewise sence, like the function below. In a full period it is NOT linear.

(2) There are NO powerful function like Piecewise function in Mathematica, and all I can use are some very basic functions including Mod, +,-, *, \, Abs, Floor, Ceiling,Exp,10^,Sin,Cos,Tan,ASin,ACos, ATan,Log and logic control commands If, If Then Else.

(3) After many times trying, I also found another challenging part is related to Mod of a negative number .My piecewise linear periodic function can thake negative integers whose Mod is so confusing to me. I can calculate the Mod of a negative number by hand, but I have no clear idea how it relates to a repeat pattern.

So is it possible to use Mathematica to find something like linear combinations of Mod functions for any periodic piecewise linear function?

For example, the periodic piecewise linear period function like this:

f[x_?IntegerQ] := 
 Piecewise[{{-10 x + 2, 1 <= x < 4}, {-5 x + 8, 4 <= x <= 10}}, True]
f[x_?IntegerQ] := f[x + 10] /; x < 1
f[x_?IntegerQ] := f[x - 10] /; x > 10
ListPlot[Table[{x, f[x]}, {x, -9, 20}]]

Any advices are highly appreciated! Thanks :)

some period piecewise linear function

I am programming a small game (with other programming language) in which I have to use Mod function to express piecewise linear period functions.

In my case, two hard parts I think exist.

(1) The periodic function is linear in the piecewise sence, like the function below. In a full period it is NOT linear.

(2) There are NO powerful function like Piecewise function in Mathematica, and all I can use are some very basic functions including Mod, +,-, *, \, Abs, Floor, Ceiling,Exp,10^,Sin,Cos,Tan,ASin,ACos, ATan,Log.

(3) After many times trying, I also found another challenging part is related to Mod of a negative number .My piecewise linear periodic function can thake negative integers whose Mod is so confusing to me. I can calculate the Mod of a negative number by hand, but I have no clear idea how it relates to a repeat pattern.

So is it possible to use Mathematica to find something like linear combinations of Mod functions for any periodic piecewise linear function?

For example, the periodic piecewise linear period function like this:

f[x_?IntegerQ] := 
 Piecewise[{{-10 x + 2, 1 <= x < 4}, {-5 x + 8, 4 <= x <= 10}}, True]
f[x_?IntegerQ] := f[x + 10] /; x < 1
f[x_?IntegerQ] := f[x - 10] /; x > 10
ListPlot[Table[{x, f[x]}, {x, -9, 20}]]

Any advices are highly appreciated! Thanks :)

some period piecewise linear function

I am programming a small game (with other programming language) in which I have to use Mod function to express piecewise linear period functions.

In my case, two hard parts I think exist.

(1) The periodic function is linear in the piecewise sence, like the function below. In a full period it is NOT linear.

(2) There are NO powerful function like Piecewise function in Mathematica, and all I can use are some very basic functions including Mod, +,-, *, \, Abs, Floor, Ceiling,Exp,10^,Sin,Cos,Tan,ASin,ACos, ATan,Log and logic control commands If, If Then Else.

(3) After many times trying, I also found another challenging part is related to Mod of a negative number .My piecewise linear periodic function can thake negative integers whose Mod is so confusing to me. I can calculate the Mod of a negative number by hand, but I have no clear idea how it relates to a repeat pattern.

So is it possible to use Mathematica to find something like linear combinations of Mod functions for any periodic piecewise linear function?

For example, the periodic piecewise linear period function like this:

f[x_?IntegerQ] := 
 Piecewise[{{-10 x + 2, 1 <= x < 4}, {-5 x + 8, 4 <= x <= 10}}, True]
f[x_?IntegerQ] := f[x + 10] /; x < 1
f[x_?IntegerQ] := f[x - 10] /; x > 10
ListPlot[Table[{x, f[x]}, {x, -9, 20}]]

Any advices are highly appreciated! Thanks :)

some period piecewise linear function

added 14 characters in body; edited title
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13
Loading
added 14 characters in body; edited title
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13
Loading
added 14 characters in body; edited title
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13
Loading
added 14 characters in body; edited title
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13
Loading
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13
Loading