1
$\begingroup$

So I'm working with "surds", or radicals. I have expressions like

$$7 + 5\sqrt{2} + 6\sqrt{3} + 7\sqrt{6}\tag{1}$$

and I want to take the "coefficients", for lack of a better word, and take their remainder when divided by $p$.

For example, if $p=4$, Equation (1) becomes:

$$3 + \sqrt{2} + 2\sqrt{3} + 3\sqrt{6}$$

...again, by taking each number in front and finding the remainder when dividing by $4$.

Also, could someone tell me what this is in mathematical terms?

$\endgroup$
  • $\begingroup$ I'm essentially looking for a function that takes something like SurdMod[$17+21\sqrt{3}+18\sqrt{5}+7\sqrt{15}$,$13$] and returns $4+8\sqrt{3}+5\sqrt{5}+7\sqrt{15}$ $\endgroup$ – Matt Groff Nov 7 at 22:13
3
$\begingroup$
surdMod[expr_, n_]:=expr /. {x_Integer y_Power -> Mod[x, n] y, x_Power :> x, 
x_Integer :> Mod[x, n]}

Testing:

surdMod[7 + 5 Sqrt[2] + 6 Sqrt[3] + 7 Sqrt[6], 4]

3 + Sqrt[2] + 2 Sqrt[3] + 3 Sqrt[6]

surdMod[17 + 21 Sqrt[3] + 18 Sqrt[5] + 7 Sqrt[15], 13]

4 + 8 Sqrt[3] + 5 Sqrt[5] + 7 Sqrt[15]

surdMod[Sqrt[14], 3]

Sqrt[14]

$\endgroup$
  • $\begingroup$ I'm not sure why, but your function sometimes takes the modulus of the surds. For instance, I had a function with $\sqrt{14}$, and it returned a $\sqrt{3}$ instead. $\endgroup$ – Matt Groff Nov 8 at 5:52
  • $\begingroup$ Oh, I see. Repaired, tested, should be working. $\endgroup$ – Alx Nov 8 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.