0
$\begingroup$

If I type

Solve[a t == 1, {a}, Complexes]

I get the solution

{{a -> 1/t}}

This is because Mathematica is treating the variable $t$ as a complex number. What I am looking for is a convenient way to look for solutions $a$ that work for all $t$, i.e. I want to treat $t$ as a degree one polynomial $p(t)=t$. In this case, there are no complex number solutions $a$ to the equation $a t = 1$.

Alternatively, is there anyway to look for solutions to an equation which depend only polynomially on the unknown variables (for example, $a=t$ would be an acceptable solution, but not $a=\frac{1}{t}$)?

$\endgroup$
  • $\begingroup$ Just assume t to be a given polynomial of order n in a by completing the system of equations and then there will be n+1 complex solutions to the equations. Otherwise the system will not try to guess what you might want. Nontheless there are some options in Solve like MaxExtraConditions, Method->Reduce etc.. Take a look e.g. at What is the difference between Reduce and Solve? $\endgroup$ – Artes Aug 8 '17 at 18:04
  • 2
    $\begingroup$ Perhaps SolveAlways[a t == 1, t] or SolveAlways[a + b t ==t, t]? $\endgroup$ – Carl Woll Aug 8 '17 at 18:14
  • $\begingroup$ Maybe In[831]:= Reduce[a t == 1, {a}, Complexes] Out[831]= t != 0 && a == 1/t ?? $\endgroup$ – Daniel Lichtblau Aug 16 '17 at 18:30
1
$\begingroup$

I've used CoefficientArrays for stuff like this.

I.e. CoefficientArrays[expression, t] will give a list of sparse-arrays of coefficients of $t^n$ in expression, where $n$ ranges from $0$ to the highest power of $t$ present.

So Flatten[Normal/@CoefficientArrays[a t == 1,t]] yields:

{-1, a}

All of which you want to be zero. So you can apply #==0&/@ the output and have all the equations you want available to pipe into Reduce or the favorite solver of your choice.

All the zeros in sparse matrices from complete set of possible monomials can be a little overwhelming especially at higher orders, so I tend to use ArrayRules as follows:

    treatAsBasisPolys[expr_, vars_] := Map[Last[#] == 0 &, 
       Flatten[(ArrayRules /@ CoefficientArrays[expr, Flatten[{vars}]]) /. 
                ArrayRules[a_] :> {} -> a  
          (* This last rule is a cheap hack to deal with the fact:
             first element returned by CoefficientArrays is a scalar *)
       ]
      ] 

Examples:

  • treatAsBasisPolys[a T == 1, T] // Reduce $\mapsto$

False

  • treatAsBasisPolys[a T == b, T] // Reduce $\mapsto$

b == 0 && a == 0

  • treatAsBasisPolys[a U + b V == c, {U, V}] // Reduce $\mapsto$

b == 0 && c == 0 && a == 0

  • treatAsBasisPolys[a u + b v + c u v == 15 u v, {u, v}] // Reduce $\mapsto$

b == 0 && c == 15 && a == 0

  • treatAsBasisPolys[a U + b V + c U V + d + q U^18 == (13 + g U) (-3 + k V), {U, V}] // Reduce $\mapsto$

d == -39 && q == 0 && c == g k && b == 13 k && a == -3 g

|improve this answer|||||
$\endgroup$

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.