## 60 Reputation

3 years, 120 days

## Simplifying terms in a differential equa...

Maple 2018

I am developing an algorythm which returns some differential equation, which I want to simplify. Here is an example:

`eqq:= k[t]*(`&ell;`^2)*(diff(q[3](tau), tau, tau)+(5*alpha-sigma+2*theta+1)*q[3](tau)+(-4*alpha+sigma-theta)*q[2](tau)+q[1](tau)*alpha) = -(sqrt(m*(1/k[t]))*`&ell;`*k[t]*`&Delta;&theta;`*(q[3](tau)-q[2](tau))*sin(sqrt(Lambda*k[t]*(1/m))*sqrt(m*(1/k[t]))*tau)+2*xi*sqrt(lambda*k[t]*m)*(diff(q[3](tau), tau)))*`&ell;`*(1/sqrt(m*(1/k[t])))`

I want the parameters to be associated to the the variables,  and their derivattives. So, I have used "collect" command, as below:

```vars:= {q[1](tau),q[2](tau),q[3](tau),diff(q[1](tau),tau),diff(q[2](tau),tau),diff(q[3](tau),tau),diff(q[1](tau),tau\$2),diff(q[2](tau),tau\$2),diff(q[3](tau),tau\$2)}:
collect(eqq,vars);
```

The problem is that the equations remain with non-simplified terms, such as the terms inside the "sine" functions and the term "k[t]*ell^2". The command "simplify" does not have any effect. Ideally, I would like to have something like this:

`(diff(q[3](tau), tau, tau))+alpha*q[1](tau)+(-4*alpha+sigma-theta)*q[2](tau)+(5*alpha-sigma+2*theta+1)*q[3](tau)+2*xi*sqrt(lambda)/`&ell;`*(diff(q[3](tau), tau))-`&Delta;&theta;`*sin(sqrt(Lambda)*tau)*q[2](tau)+`&Delta;&theta;`*q[3](tau)*sin(sqrt(Lambda)*tau) = 0;`

Does anyone know how to solve that?

## Greek letter with subscript in the legen...

Maple

I would like to plot a graph whose legend has a Greek character with a numeric subscript. Below, there is a small example, where I show what I am trying to do:

```restart:

# Simplified example, which is not working:

omega0:= 10:
plot(omega^2/omega0, omega = 1..1.5,
legend = [sprintf("%s = %.1f",`&omega;`[0],omega0)]);

# The character I want to be plotted inside the legend:

`&omega;`[0];```

I suppose the problem is that " `&omega;[0]` is not considered a string and, therefore, I can not call it in the legend with a "%s". I do not know how to make it work, though. Does anyone know how to do so?

## Efficiently defining a fourth-order tens...

Maple

I would like to define a fourth-order tensor (3x3x3x3) with zeros, for then defining some non-null terms individually. For that, I'm currently doing:

```for it1 from 1 to 3 do
for it2 from 1 to 3 do
for it3 from 1 to 3 do
for it4 from 1 to 3 do
H[it1,it2,it3,it4]:= 0;
end do:
end do:
end do:
end do:

H[1,1,1,1]:= value1:
H[1,2,2,1]:= value2:
# etc.
```

However, I suppose there is probably a more efficient manner to do do, maybe using Physics package. Does anyone know to do that?

## Problem when substituting terms in an eq...

Maple 2018

I have the following equation:

`eqn := m*`&ell;`^2*(diff(q[1](t), t, t))+k[t]*`&ell;`^2*q[1]+5*k[r]*q[1]-4*k[r]*q[2]+k[r]*q[3]-5*P*`&ell;`*q[1]+2*`&ell;`*P*q[2]+2*`&ell;`*T*q[1]-`&ell;`*T*q[2] = 0;`

And I want to execute the following substitutions:

`k[r]/(k[t]*`&ell;`^2) = alpha;`
`P/(k[t]*`&ell;`) = sigma`
`T/(k[t]*`&ell;`) = theta`

For that, I have tried:

```expand(eqn/(k[t]*`&ell;`^2));
eqn1:= algsubs({k[r]/(k[t]*`&ell;`^2) = alpha, P/(k[t]*`&ell;`) = sigma, T/(k[t]*`&ell;`) = theta}, %);
```

And:

```eqn1:= algsubs(k[r]/(k[t]*`&ell;`^2) = alpha, %);
eqn2:= algsubs(P/(k[t]*`&ell;`) = sigma, %);
eqn3:= algsubs(T/(k[t]*`&ell;`) = theta, %);```

But none of these have worked. Does anyone know how to solve this?

## Method of Multiple Scales ...

Maple

So, I'm trying to delelop an algorithm for the method of multiple scales. Starting with a simple ODE:

After scaling, it should be written in the form:

A proto-algorithm would be:

```restart;
ode := diff(x(t), `\$`(t, 2))+x(t) = 0;
i_ini := 1; i_fin := 3; j_ini := 0; j_fin := 2;
PDEtools:-dchange({t = sum(epsilon^j*T[j], j = j_ini .. j_fin), x(t) = sum(epsilon^i*X[i](T[1]), i = i_ini .. i_fin)}, ode, [{T[0], T[1], T[2]}, {X[1], X[2], X[3]}])```

It is not working, though. Could anyone help me out?