Jump to content



Photo
- - - - -

Mod(x,y) ?


  • Please log in to reply
8 replies to this topic

#1 MasterJoda800

MasterJoda800

    Newbie

  • Members
  • Pip
  • 5 posts

  • Calculators:
    ClassPad300, CFX9850G

Posted 19 April 2005 - 07:41 AM

I found a problem in the mod() function.
If i use it with numbers it works fine
(e.g. mod(5,2)=1)
but if i try to use it with variables it behaves very strange
e.g.
mod(x,y) gives x as result <_<

although x and y are both undefined (they have no value)

I found this when trying to use mod in a while construction in my program that calculates a mod function. It gives very strange results. :banghead:

Does anyone know whats wrong with it?

thanks

#2 TacoFred

TacoFred

    Casio Freak

  • Members
  • PipPipPipPip
  • 145 posts
  • Location:NJ
  • Interests:I LOVE STARCRAFT BROODWAR<br />MUHAHAHAHAHAHAHAHAHAHAHA

  • Calculators:
    cfx 9850gb+, fx 115MS, ClassPad 300, TI-89 Titanium

Posted 19 April 2005 - 09:10 AM

well, since x and y are not defined, the calc's modulus function has no way of calculating a remainder value, and cannot print out anything else
it would make more sense to output an error in my opinion......

#3 Guest_Guest_masterjoda800_*_*

Guest_Guest_masterjoda800_*_*
  • Guests

Posted 19 April 2005 - 01:54 PM

at first thanks for your answer.

Well sure, thats right.
But try the following:

In Graph/Table Menu insert the following function:
y1=mod(x,5)
then let the classpad create a table thats starts with 0 and ends with 12 or 13 ore something like that
it creates a table that looks like this:

x | y1
--+----
0 | 0
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
6 | 6
7 | 7
8 | 8
9 | 9
10 | 10
11 | 11

but thats not correct. It normaly schould calculate a table that looks like that:

x | y1
--+----
0 | 0
1 | 1
2 | 2
3 | 3
4 | 4
5 | 0
6 | 1
7 | 2
8 | 3
9 | 4
10 | 0
11 | 1

so whats wrong?

#4 Daruosh

Daruosh

    Casio Freak

  • Members
  • PipPipPipPip
  • 285 posts
  • Gender:Male
  • Location:Tehran - Iran
  • Interests:Computer Programming, Electronics, Image Processing, Neural Networks, AI, System Development, Calc, Guitar, Music,

  • Calculators:
    CP 300 OS 3.03, Algebra FX 2.0 Plus ROM 1.05, CG-20

Posted 19 April 2005 - 06:23 PM

Same here, Is it a BUG??

#5 SoftCalc

SoftCalc

    Casio Technician

  • Members
  • PipPipPipPipPipPip
  • 406 posts
  • Location:Portland, OR USA

  • Calculators:
    ClassPad 300 , AFX 2.0, HP-48/49/50, TI-89/92/Voyager, HP Expander, etc...

Posted 19 April 2005 - 11:08 PM

mod(x,y) gives x as result
Does anyone know whats wrong with it?

<{POST_SNAPBACK}>


It is doing a polynomial "mod". Try mod(x^2+4*x+3,x^2+3*x+2) and you'll see what I mean ;)

#6 Guest_Guest_masterjoda800_*_*

Guest_Guest_masterjoda800_*_*
  • Guests

Posted 20 April 2005 - 10:17 AM

hmm, and what does that mean for the bug?
sorry, but i cant follow you

#7 SoftCalc

SoftCalc

    Casio Technician

  • Members
  • PipPipPipPipPipPip
  • 406 posts
  • Location:Portland, OR USA

  • Calculators:
    ClassPad 300 , AFX 2.0, HP-48/49/50, TI-89/92/Voyager, HP Expander, etc...

Posted 20 April 2005 - 03:57 PM

Well it is a bug, and it isn't.... "mod" will give a result with variables because it is doing a polynomial "mod". For the following case where you've entered to polynomials it is a very nice feature...mod(x^2+4*x+3,x^2+3*x+2) :arrow: x+1
If, on the other hand, you want to use a variable as a placeholder, it is a very bad feature....mod(x,5) :arrow: 5
What it is doing in the graph/table is correct, but not expected. It is doing a polynomial "mod" when what you want is a numeric "mod" where "x" is a placeholder.

The graph and table application pre-evaluates the expression to speed things up. As an example, a complicated integral will graph much faster if it is pre-evaluated and reduced before graphing. In this case though, it is "pre-evaluating" "mod(x,5)" and getting "x".

NOTE: The same problem exists with the "gcd" function.

#8 Guest_Guest_mkanter_*_*

Guest_Guest_mkanter_*_*
  • Guests

Posted 22 April 2005 - 10:06 AM

Well it is a bug, and it isn't.... "mod" will give a result with variables because it is doing a polynomial "mod". For the following case where you've entered to polynomials it is a very nice feature...mod(x^2+4*x+3,x^2+3*x+2) :arrow: x+1
If, on the other hand, you want to use a variable as a placeholder, it is a very bad feature....mod(x,5) :arrow: 5
What it is doing in the graph/table is correct, but not expected. It is doing a polynomial "mod" when what you want is a numeric "mod" where "x" is a placeholder.

The graph and table application pre-evaluates the expression to speed things up. As an example, a complicated integral will graph much faster if it is pre-evaluated and reduced before graphing. In this case though,  it is "pre-evaluating" "mod(x,5)" and getting "x".

NOTE: The same problem exists with the "gcd" function.

<{POST_SNAPBACK}>



but then it should give some conditions on the solution like:

mod(x, 5) =
x | 0<= x < 5

I think the solution of the example above may be wrong too, if you will insert some big or small x (to met not the not given conditions of solution)

#9 Lianna

Lianna

    Newbie

  • Members
  • Pip
  • 14 posts

  • Calculators:
    ClassPad 300
    CFX-9850G

Posted 22 May 2005 - 09:43 PM

I think the function you [MasterJoda] were looking for is:
Define moda(x,y)=simplify(x-y*int(x/y))
Define modap(x,y)=simplify(x-y*intg(x/y))
seq(moda(x,3),x,-5,5,1)
seq(modap(x,3),x,-5,5,1)
Difference is in negative x values.
Best regards,
Lianna




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users