How to solve simultaneous congruences equations in r

221 views Asked by At
3x ≡ 7(mod2)
2x ≡ 5(mod3)
5x ≡ 4(mod7)

I solved this congruences in R, like given below

> modlin(3,7,2)
[1] 1
> modlin(2,5,3)
[1] 1
> modlin(5,4,7)
[1] 5
> a<-c(1,1,5)
> m<-c(2,3,7)
> chinese(a,m)
[1] 19
> prod(2,3,7)
[1] 42

So, I got the correct answer x=19(mod 42)

In this case, GCD(2,3,7)=1, suppose ax≡b(mod p), cx≡d(mod q), gx≡h(mod s) with GCD(p,q,s) is not equal to 1 then i know how to solve this equation using extension of Chinese Remainder Theorem by hand but i don't know in R. Please tell me to solve in R ??

0

There are 0 answers