Solving equations with mod in Sage

4.8k Views Asked by At

I'm trying to use Sage to solve equations, but can't seem to get a toy example running.

Lets say I want to solve for x, where x=(1/17) mod 780, the answer should be 413.

I define a variable in Sage as:

sage: var('x')

Then I try to solve using:

sage: func=(x==(1/17)%780)

sage: solve(func)

However it just returns the message IndexError: tuple index out of range.

Any idea what I'm doing wrong? I believe the double equals == is the right syntax for the "equals" in an equation for Sage.

1

There are 1 best solutions below

1
On BEST ANSWER

You could use solve mod, like $\text{solve_mod(x==(1/17),780)}$

You can run this in the online https://cocalc.com/ or with https://sagecell.sagemath.org/

You can see more examples at; https://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/relation.html