Skip to main content
Actually, keep CirclePlus unevaluated until it gets an argument.
Source Link
Carl Woll
  • 132.7k
  • 6
  • 253
  • 366

This is how I would define your functions, similar but I think simpler than @Jens answer:

ClearAll[CirclePlus, CircleTimes, CenterDot] SetAttributes[CirclePlus, {Flat, Listable}] CirclePlus[a__]CirclePlus[a__][x_] := Activate @* Through @* Inactive[Plus][a] @ x CircleTimes[a_, b_] := Inner[Composition, a, b, CirclePlus] CenterDot[a_, b_] := Inner[Compose, a, b] 

For the OP example:

I1 := {{0&, (x # + D[#,x]&)}, {0&, -D[#,x]&}} I2 := {{0&, x^2 #&}, {0&, D[#,x]&}} u = {f[x], g[x]}; 

The same results as @Jens:

CenterDot[I1, u] //TeXForm 

$\left\{g'(x)+x g(x),-g'(x)\right\}$

CenterDot[I2, u] //TeXForm 

$\left\{x^2 g(x),g'(x)\right\}$

CenterDot[CircleTimes[I1, I2], u] //TeXForm 

$\left\{g''(x)+x g'(x),-g''(x)\right\}$

I3 := CirclePlus[CircleTimes[I1, I2], CircleTimes[I2, I1]] CenterDot[I3, u] //TeXForm 

$\left\{g''(x)+x^2 \left(-g'(x)\right)+x g'(x),-2 g''(x)\right\}$

Id := {{1&, 0&}, {0&, 1&}} CenterDot[CirclePlus[Id, Id], u] //TeXForm 

$\{2,2\}$

This is how I would define your functions, similar but I think simpler than @Jens answer:

ClearAll[CirclePlus, CircleTimes, CenterDot] SetAttributes[CirclePlus, {Flat, Listable}] CirclePlus[a__] := Activate @* Through @* Inactive[Plus][a] CircleTimes[a_, b_] := Inner[Composition, a, b, CirclePlus] CenterDot[a_, b_] := Inner[Compose, a, b] 

For the OP example:

I1 := {{0&, (x # + D[#,x]&)}, {0&, -D[#,x]&}} I2 := {{0&, x^2 #&}, {0&, D[#,x]&}} u = {f[x], g[x]}; 

The same results as @Jens:

CenterDot[I1, u] //TeXForm 

$\left\{g'(x)+x g(x),-g'(x)\right\}$

CenterDot[I2, u] //TeXForm 

$\left\{x^2 g(x),g'(x)\right\}$

CenterDot[CircleTimes[I1, I2], u] //TeXForm 

$\left\{g''(x)+x g'(x),-g''(x)\right\}$

I3 := CirclePlus[CircleTimes[I1, I2], CircleTimes[I2, I1]] CenterDot[I3, u] //TeXForm 

$\left\{g''(x)+x^2 \left(-g'(x)\right)+x g'(x),-2 g''(x)\right\}$

Id := {{1&, 0&}, {0&, 1&}} CenterDot[CirclePlus[Id, Id], u] //TeXForm 

$\{2,2\}$

This is how I would define your functions, similar but I think simpler than @Jens answer:

ClearAll[CirclePlus, CircleTimes, CenterDot] SetAttributes[CirclePlus, {Flat, Listable}] CirclePlus[a__][x_] := Activate @* Through @* Inactive[Plus][a] @ x CircleTimes[a_, b_] := Inner[Composition, a, b, CirclePlus] CenterDot[a_, b_] := Inner[Compose, a, b] 

For the OP example:

I1 := {{0&, (x # + D[#,x]&)}, {0&, -D[#,x]&}} I2 := {{0&, x^2 #&}, {0&, D[#,x]&}} u = {f[x], g[x]}; 

The same results as @Jens:

CenterDot[I1, u] //TeXForm 

$\left\{g'(x)+x g(x),-g'(x)\right\}$

CenterDot[I2, u] //TeXForm 

$\left\{x^2 g(x),g'(x)\right\}$

CenterDot[CircleTimes[I1, I2], u] //TeXForm 

$\left\{g''(x)+x g'(x),-g''(x)\right\}$

I3 := CirclePlus[CircleTimes[I1, I2], CircleTimes[I2, I1]] CenterDot[I3, u] //TeXForm 

$\left\{g''(x)+x^2 \left(-g'(x)\right)+x g'(x),-2 g''(x)\right\}$

Id := {{1&, 0&}, {0&, 1&}} CenterDot[CirclePlus[Id, Id], u] //TeXForm 

$\{2,2\}$

Improve CirclePlus of operators
Source Link
Carl Woll
  • 132.7k
  • 6
  • 253
  • 366

This is how I would define your functions, similar but I think simpler than @Jens answer:

ClearAll[CirclePlus, CircleTimes, CenterDot] SetAttributes[CirclePlus, {Flat, Listable}] CirclePlus[a__][x_]CirclePlus[a__] := TotalActivate @* Through @* {a} @ xInactive[Plus][a] CircleTimes[a_, b_] := Inner[Composition, a, b, CirclePlus] CenterDot[a_, b_] := Inner[Compose, a, b] 

For the OP example:

I1 := {{0&, (x # + D[#,x]&)}, {0&, -D[#,x]&}} I2 := {{0&, x^2 #&}, {0&, D[#,x]&}} u = {f[x], g[x]}; 

The same results as @Jens:

CenterDot[I1, u] //TeXForm 

$\left\{g'(x)+x g(x),-g'(x)\right\}$

CenterDot[I2, u] //TeXForm 

$\left\{x^2 g(x),g'(x)\right\}$

CenterDot[CircleTimes[I1, I2], u] //TeXForm 

$\left\{g''(x)+x g'(x),-g''(x)\right\}$

I3 := CirclePlus[CircleTimes[I1, I2], CircleTimes[I2, I1]] CenterDot[I3, u] //TeXForm 

$\left\{g''(x)+x^2 \left(-g'(x)\right)+x g'(x),-2 g''(x)\right\}$

Id := {{1&, 0&}, {0&, 1&}} CenterDot[CirclePlus[Id, Id], u] //TeXForm 

$\{2,2\}$

This is how I would define your functions, similar but I think simpler than @Jens answer:

ClearAll[CirclePlus, CircleTimes, CenterDot] SetAttributes[CirclePlus, {Flat, Listable}] CirclePlus[a__][x_] := Total @* Through @* {a} @ x CircleTimes[a_, b_] := Inner[Composition, a, b, CirclePlus] CenterDot[a_, b_] := Inner[Compose, a, b] 

For the OP example:

I1 := {{0&, (x # + D[#,x]&)}, {0&, -D[#,x]&}} I2 := {{0&, x^2 #&}, {0&, D[#,x]&}} u = {f[x], g[x]}; 

The same results as @Jens:

CenterDot[I1, u] //TeXForm 

$\left\{g'(x)+x g(x),-g'(x)\right\}$

CenterDot[I2, u] //TeXForm 

$\left\{x^2 g(x),g'(x)\right\}$

CenterDot[CircleTimes[I1, I2], u] //TeXForm 

$\left\{g''(x)+x g'(x),-g''(x)\right\}$

I3 := CirclePlus[CircleTimes[I1, I2], CircleTimes[I2, I1]] CenterDot[I3, u] //TeXForm 

$\left\{g''(x)+x^2 \left(-g'(x)\right)+x g'(x),-2 g''(x)\right\}$

Id := {{1&, 0&}, {0&, 1&}} CenterDot[CirclePlus[Id, Id], u] //TeXForm 

$\{2,2\}$

This is how I would define your functions, similar but I think simpler than @Jens answer:

ClearAll[CirclePlus, CircleTimes, CenterDot] SetAttributes[CirclePlus, {Flat, Listable}] CirclePlus[a__] := Activate @* Through @* Inactive[Plus][a] CircleTimes[a_, b_] := Inner[Composition, a, b, CirclePlus] CenterDot[a_, b_] := Inner[Compose, a, b] 

For the OP example:

I1 := {{0&, (x # + D[#,x]&)}, {0&, -D[#,x]&}} I2 := {{0&, x^2 #&}, {0&, D[#,x]&}} u = {f[x], g[x]}; 

The same results as @Jens:

CenterDot[I1, u] //TeXForm 

$\left\{g'(x)+x g(x),-g'(x)\right\}$

CenterDot[I2, u] //TeXForm 

$\left\{x^2 g(x),g'(x)\right\}$

CenterDot[CircleTimes[I1, I2], u] //TeXForm 

$\left\{g''(x)+x g'(x),-g''(x)\right\}$

I3 := CirclePlus[CircleTimes[I1, I2], CircleTimes[I2, I1]] CenterDot[I3, u] //TeXForm 

$\left\{g''(x)+x^2 \left(-g'(x)\right)+x g'(x),-2 g''(x)\right\}$

Id := {{1&, 0&}, {0&, 1&}} CenterDot[CirclePlus[Id, Id], u] //TeXForm 

$\{2,2\}$

Source Link
Carl Woll
  • 132.7k
  • 6
  • 253
  • 366

This is how I would define your functions, similar but I think simpler than @Jens answer:

ClearAll[CirclePlus, CircleTimes, CenterDot] SetAttributes[CirclePlus, {Flat, Listable}] CirclePlus[a__][x_] := Total @* Through @* {a} @ x CircleTimes[a_, b_] := Inner[Composition, a, b, CirclePlus] CenterDot[a_, b_] := Inner[Compose, a, b] 

For the OP example:

I1 := {{0&, (x # + D[#,x]&)}, {0&, -D[#,x]&}} I2 := {{0&, x^2 #&}, {0&, D[#,x]&}} u = {f[x], g[x]}; 

The same results as @Jens:

CenterDot[I1, u] //TeXForm 

$\left\{g'(x)+x g(x),-g'(x)\right\}$

CenterDot[I2, u] //TeXForm 

$\left\{x^2 g(x),g'(x)\right\}$

CenterDot[CircleTimes[I1, I2], u] //TeXForm 

$\left\{g''(x)+x g'(x),-g''(x)\right\}$

I3 := CirclePlus[CircleTimes[I1, I2], CircleTimes[I2, I1]] CenterDot[I3, u] //TeXForm 

$\left\{g''(x)+x^2 \left(-g'(x)\right)+x g'(x),-2 g''(x)\right\}$

Id := {{1&, 0&}, {0&, 1&}} CenterDot[CirclePlus[Id, Id], u] //TeXForm 

$\{2,2\}$