0
$\begingroup$

I am solving a system of first-order equations using matrix operations and the Laplace Transform. I begin with the matrix equation that represents the solution to my system, like this:

$$ \underline{\underline{\mathbf{m}}} \mathcal{L} { \mathbf{N}(t) } = \mathbf{N_0}$$

Bold symbols are vectors (functions) and double-underlined symbols are matrix. $\mathcal{L}$ is the Laplace Transform.

To make this computation I first write and invert the matrix $\underline{\underline{m}}$.

m[s_, l1_, l2_] := {{s + l1, 0}, {-l1, s + l2}}
invm[s_, l1_, l2_] := Inverse[m[s, l1, l2]]

Mathematica graphics

Then I can input the initial conditions:

Subscript[N, 0] = {1, 0}

Then I use the inverse to get the Laplace transform of the (vector) solution:

R0[s_, l1_, l2_] := invm[s, l1, l2] . Subscript[N, 0]

Then, the final solution is simply an inverse Laplace Transform of this resulting vector, so I attempt:

N[t_, l1_, l2_] := Simplify[InverseLaplaceTransform[R0[s, l1, l2], s, t]]

But this command results in the error:

Mathematica graphics

Can I get the inverse Laplace Transform to work on a vector in order to simplify my notation going forward?

$\endgroup$
2
  • 1
    $\begingroup$ Subscript[N, 0] = {1, 0} Do not use N as variable name, this is a function name in Mathematica. gives the numerical value of expr. Try with another lower case letter and see if this fixes the issue you are having. Also, I would avoid using Subscript in Mathematica myself. The less fancy letters you use, the less problems you will have. You can use indexed variables instead if you must. $\endgroup$
    – Nasser
    May 28, 2023 at 4:12
  • 1
    $\begingroup$ And the actual error is coming from your call N[t_, l1_, l2_] . Again N is builtin function. Try n[t_, l1_, l2_] and also remove the use of the other N you had before. $\endgroup$
    – Nasser
    May 28, 2023 at 4:25

1 Answer 1

2
$\begingroup$

I do not understand your use of Subscript[N, 0] = {1, 0} actually and what it is for? So I might be overlooking something here. But why not just

ClearAll["Global`*"]
m[s_Symbol,l1_,l2_]:={{s+l1,0},{-l1,s+l2}}
invm[s_Symbol,l1_,l2_]:=Inverse[m[s,l1,l2]]
R0[s_Symbol,l1_,l2_]:=invm[s,l1,l2].{1,0}
n[t_Symbol,l1_,l2_,s_Symbol]:=Simplify[InverseLaplaceTransform[R0[s,l1,l2],s,t]]
n[t,2,3,s]

Mathematica graphics

I would pass all the symbols involved, this includes $t$ and also $s$. Avoid using global symbols as they could be assigned to some values in your notebook.

$\endgroup$
1
  • $\begingroup$ Well the Subscript[N,0] = {1,0} was just because the notation made sense, no particular reason. I didn't know N[] was protected, so that is the answer. $\endgroup$
    – villaa
    May 28, 2023 at 19:10

Your Answer

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

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