1
$\begingroup$

I am interested in expanding a vector expression in terms of the scalar parameter, but it doesn't give the expected result

$Assumptions = (ϵ) ∈ Reals;
$Assumptions = (r | k) ∈ Vectors[3, Reals];

A[r_] := Module[{M},
$Assumptions = r ∈ Vectors[3, Reals];
M = r + k*ϵ // Simplify;
Return[M]
];

q[r_] := Module[{M},
$Assumptions = r ∈ Vectors[3, Reals];
M = ϵ*(r\[Cross]A[r]) + ϵ*r // Simplify;
Return[M]
];

q[r]

Coefficient[Expand[TensorReduce[q[r]], ϵ], ϵ, 1]

Coefficient[Expand[TensorReduce[q[r]], ϵ], ϵ, 2]

Edit:

Output of the first Coefficient is

    r + r\[Cross](r + k ϵ)

and should be

   r+ r\[Cross]r (* same as just r *)

and output of the second Coefficient is

   0

and should be

  r\[Cross]k
$\endgroup$
6
  • $\begingroup$ "doesn't give the expected result" - what is the expected result? $\endgroup$
    – Jason B.
    Aug 28, 2018 at 13:36
  • $\begingroup$ You really don't need to use Module for these functions, you could rewrite them as A[r_] := Assuming[r ∈ Vectors[3, Reals], r + k*ϵ // Simplify ]; q[r_] := Assuming[r ∈ Vectors[3, Reals], ϵ*(r\[Cross]A[r]) + ϵ*r // Simplify ]; $\endgroup$
    – Jason B.
    Aug 28, 2018 at 13:39
  • $\begingroup$ same problem with this. The expected result is r for the first Coefficient and r x k for the second one. $\endgroup$ Aug 28, 2018 at 13:54
  • 2
    $\begingroup$ I can't really help on that, just trying to help formulate the question better. It doesn't really have anything to do with the Module, so the title of the question should be changed. Next, you should edit the question to show what output you do get and what output you expect. $\endgroup$
    – Jason B.
    Aug 28, 2018 at 14:02
  • 1
    $\begingroup$ You need to use $Assumptions = ϵ∈Reals && (r|k)∈Vectors[3,Reals] at the top, and remove the redefinitions of $Assumptions in your code. $\endgroup$
    – Carl Woll
    Aug 28, 2018 at 14:27

1 Answer 1

2
$\begingroup$

When you set the value of $Assumptions, the old value of $Assumptions is lost. Instead, use Assuming:

WolframLanguageData["Assuming","PlaintextUsage"]

Assuming[assum, expr] evaluates expr with assum appended to $Assumptions, so that assum is included in the default assumptions used by functions such as Refine, Simplify, and Integrate.

In your case you need to use Assuming when you call TensorReduce. So:

$Assumptions = ϵ∈Reals && (r|k)∈Vectors[3, Reals];

A[r_] := r + k ϵ

q[r_] := ϵ (r \[Cross] A[r]) + ϵ r

expanded = Assuming[rp ∈ Vectors[3, Reals], Expand @ TensorReduce[q[rp]]]

Coefficient[expanded, ϵ, 1]

Coefficient[expanded, ϵ, 2]

rp ϵ - ϵ^2 k \[Cross] rp

rp

-k \[Cross] rp

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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