0
$\begingroup$

I have a polynomial (functional) expression $E[F]$ in terms of a function $F$.

I want to take an $F$-cube truncation in the sense that I want to and make terms of the form $F[w]F[x]F[y]F[z]$ vanish for any value of the arguments $w,\ldots,z$ that are not real variables but complicated to describe and (thus not realistic to list).

For concreteness, take $F(x)=\sin(x)$; one could imagine $D$, the domain of $F$, has cardinality $1000$ (which is why I would not like to list $1000^4$ evaluated elements) and I'd like to neglect $\mathcal O (\sin^4)$-terms, in the sense described above. An example would be

Truncation of

$$\sin^2(v)\sin(w)\sin^2(x)\sin^2(w) \sin(y)+ \sin^2(x) \sin(y) \sin(w)+\sin(w)\sin(x)\sin(y)+ 2\sin(y) + 3 $$

to be for all $v,w,x,y,z$

$$ \sin(w)\sin(x)\sin(y)+2\sin(y) +3 $$

i.e.

Sin[v]^2 Sin[w]Sin[x]^2 Sin[w] ^2 Sin[y] + Sin[x]^2 Sin[y] Sin[w]+Sin[w] Sin[x] Sin[y]+ 2Sin[y] + 3 

(*should yield ==>>  Sin[w] Sin[x] Sin[y]+ 2Sin[y] + 3*)

How to annihilate multiple products of the image of a custom function? So I start it making the truncation linear

VariableList={(*not easy to describe*)}
Truncation[x_Plus] := Truncation[#] & /@ x
Truncation[c_ x_] := c Truncation[x] /; And @@ FreeQ[c, VariableList])

where x_ would be a polynomial in $F[x_1] \cdots F[x_n]$. But

Count[expr_implying_F , F]

yields 0 since $F$ is a head.

Also the suggested Count[expr_, _F, All] does not work because of:

Count[F[y] F[x] F[z] F[w] , _F, All] (*yielding 4 as it should*)
Count[F[x] F[x] F[x] F[w] , _F, All] (*yielding 2, it should be 4*)
Count[F[x] F[x] F[x] F[x] , _F, All] (*yielding 1, it should be 4*)
  • This counting has been solved here for $F(x)=\sqrt x$, but the soulution relies on properties of the square root.

  • The solution should not refer to properties of the function $F$, e.g. in the example, not to evoke trigonometric identities.

$\endgroup$
4
  • $\begingroup$ Since your immediate problem hinges on an issue with Counts, can you give a toy expression together with your desired output. Also, would Count[yourexpression, _F, All] do what you want? $\endgroup$ – MarcoB Jun 8 '20 at 13:56
  • $\begingroup$ Do you mean Mma examples additional to the mathematical ones? $\endgroup$ – João Jun 8 '20 at 14:35
  • 1
    $\begingroup$ Powers are automatically evaluated before Count is applied. Try Count[Hold[yourExpression], _F, All]. For instance Count[Hold[F[x] F[x]], _F, All] returns 2. It will still be difficult to avoid evaluation everywhere though. You may have to look into writing an auxiliary function with a Hold attribute, or use Inactive or Unevaluated through your code. $\endgroup$ – MarcoB Jun 8 '20 at 15:17
  • 2
    $\begingroup$ And yes, I do mean MMA ones rather than mathematical ones. Don't discourage possible helpers by forcing them to rewrite your expressions by hand! Provide copy-pastable code. As a small example, see if this helps towards your ultimate goal: Sin[v]^2 Sin[w] Sin[x]^2 + 3 /. Power[Sin[__], 2] -> 1 which returns 3 + Sin[w] by "eliminating" all squared Sin expressions. $\endgroup$ – MarcoB Jun 8 '20 at 15:18
1
$\begingroup$

Try this:

expr = Sin[v]^2 Sin[w] Sin[x]^2 Sin[w]^2 Sin[y] + 
  Sin[x]^2 Sin[y] Sin[w] + Sin[w] Sin[x] Sin[y] + 2 Sin[y] + 3;

We will exchange any Sin[something]->ϵ*Sin[someting] and then expand in series in terms of ϵ:

expr2=Series[expr /. Sin[x_] -> ϵ*Sin[x], {ϵ, 0,3}] // Normal

(* 3 + 2 ϵ Sin[y] + ϵ^3 Sin[w] Sin[x] Sin[y] *)

After that one only need to put ϵ=1. Finally

expr2 /. ϵ -> 1

(*  3 + 2 Sin[y] + Sin[w] Sin[x] Sin[y]  *)

Have fun++!

$\endgroup$
1
  • $\begingroup$ That's a very nice solution! $\endgroup$ – João Jun 9 '20 at 7:31

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.