I'm completely new to Mathematica (used previously only for very simple cases). I need to write a quite complex function. The function must do the following:
Input consists of two numbers: a and b.
Factorization of expression a * (27*b^2 + a^6) must be performed, i.e. FactorInteger
For each prime factor powered by its exponent from the factorization of prevoius step the following procedure must be performed:
Reduce[{(x + a)^3 == -b, x^3 == -b}, x, Modulus -> f],
where f is that powered prime factor.
Basically, it solves the system of two cubic congruences by modulo prime power.
That solutions for prime factors must be placed in ChineseRemainder and output of it should be returned.
For example, for a = 17 and b = 697 function should return 5675. I can do it step by step but can't combine it in function.
Please help.
EDIT. Pseudocode (Python-like + Mathematica):
def MyFunc(a, b):
T = []
F = FactorInteger[a * (27*b^2 + a^6)]
# assuming F is of form [(p1,e1), (p2,e2),...]
for f in F:
p = f[0]^f[1]
# assuming Reduce returns 'x -> <num_value>'
Reduce[{(x + a)^3 == -b, x^3 == -b}, x, Modulus -> p]
T.append(tuple(<numvalue>,p))
return ChineseRemainder[T]
a=17
andb=697
,a*(27*b^2 + a^6)
is 633325004. This has 4 as one factor.Solve[{(x + a)^3 == -b, x^3 == -b} /. {a -> 17, b -> 697}, x, Modulus -> 4]
claims there is no solution. $\endgroup$