1
$\begingroup$

I have this code currently:

ClearAll["Global`*"]
f[ϕ[x, t]] = (1/4)*ϕ[x, t]^2*(1 - ϕ[x, t])^2; 
Ephi = Derivative[1][f][ϕ[x, t]] - ϵ^2*
    D[ϕ[x, t], {x, 2}]; 
u1 = (-(k + k0))*(D[p[x, t], x] - Ephi*D[ϕ[x, t], x]) - 
   k0*(1 - ϕ[x, t])*D[Ephi, x] - D[ψ[x, t], x]; 
u2 = (-(k + kw))*(D[p[x, t], x] - Ephi*D[ϕ[x, t], x]) + 
   kw*ϕ[x, t]*D[Ephi, x]; 
J = (-M)*ϕ[x, t]*D[Ephi, x];

eq1 = D[ϕ[x, t], t] + D[u1*ϕ[x, t], x] == -D[J, x]
eq2 = D[u1*ϕ[x, t] + u2*(1 - ϕ[x, t]), x] == 0;

The output when the line defining $eq1$ is not suppressed looks like: output What I'm wondering is why this output doesn't automatically calculate the derivatives of $f$ based on the second line of my code? i.e. given that: $$ f(\phi) =\frac{1}{4}\phi^2(1-\phi)^2 \implies f'(\phi)=\frac{1}{2}\left(2\phi^3-3\phi^2+\phi \right) $$ But why doesn't Mathematica replace $f'(\phi(x,t)$ in the output with this expression? It's not overly important and I know I can use a replacement rule to manually do this, but I am rather new to Mathematica and trying to figure what the program is actually doing.

$\endgroup$
3
  • 2
    $\begingroup$ Your definition of f doesn't need to involve \phi. Try something like f[u_] := 1/4 (1 - u)^2 u^2 $\endgroup$
    – mikado
    Aug 16, 2022 at 20:49
  • $\begingroup$ Is that random Psi supposed to be in there with all those Phi's? $\endgroup$ Aug 16, 2022 at 23:03
  • $\begingroup$ yes that's not a typo - it represents a force of an unknown form $\endgroup$
    – Mjoseph
    Aug 17, 2022 at 18:14

1 Answer 1

1
$\begingroup$

The comment by @mikado is a fine answer, and I am providing another one and a point of confusion that was not stressed in the original question explicitly.

The following

ClearAll["Global`*"]
f[φ[x, t]] = (1/4)*φ[x, t]^2*(1 - φ[x, t])^2;
Expand@D[f[φ[x, t]], φ[x, t]]

returns

right

So, out of curiosity we can try

ClearAll["Global`*"]
D[f[φ[x, t]], φ[x, t]] // InputForm

screen2

And hence, one would thing that in my proposed solution Derivative[1][f][φ[x, t]] would also give the right answer, but

ClearAll["Global`*"]
f[φ[x, t]] = (1/4)*φ[x, t]^2*(1 - φ[x, t])^2;
Expand@Derivative[1][f][φ[x, t]]

returns

screen3

I know I am not the best and brightest and I have not been very active recently, but the above seems weird unless I am missing something very obvious.

$\endgroup$
2
  • 1
    $\begingroup$ I haven't been very active recently, either. It seems that we have not followed the activity of the ten ways to solve something :). $\endgroup$ Aug 16, 2022 at 21:49
  • 1
    $\begingroup$ @E.Chan-López I had to move and I have another one comping up. Hopefully, by the end of September I can be back more frequently. I hope you are doing well. Also hope to reinstate the tenfold/ten ways challenge :) $\endgroup$
    – bmf
    Aug 16, 2022 at 21:53

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.