0
|
3037 Views
|
5 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Issue with definition in symbolic manipulation

Posted 10 years ago
 Hello, I was a heavy user of Mathematica during my Ph.D... Which is a bit far, now (12 years ago). I'm trying to use it again, but I'm getting mad with some subtle features. Here is the issue. I define something like OrderDev = 1; i = 0; [Eta][x, t] := Sum [Subscript[K, n][t] x^(2 n)/(2 n)!, {n, 0, OrderDev}]; [CapitalDelta][x, z, t_] := z - Subscript[K, 0][t]; Subscript[[CapitalPhi], i][x, z, t] := -Sum [ Subscript[[Phi], i , n][t] Cos[ n x - i Pi] Exp[-n [CapitalDelta][x, z, t]], {n, 1, OrderDev}]; When I define, for example, Subscript[dxphi, i_][x, z, t_] := D[Subscript[[CapitalPhi], i][x, z, t], x]; It gives what I expect : E^(-z + Subscript[K, 0][t]) Sin[x] Subscript[[Phi], 0, 1][t] But when I try to take the value of dxphi when z=eta[x,t], it seems to perform the derivation again. For example, if I ask what is Subscript[dxphi, i][x, [Eta][x, t], t] , instead of getting E^([K, 1][t] x^2 /2) Sin[x] Subscript[[Phi], 0, 1][t] , I get E^(-(1/2) x^2 Subscript[K, 1][t]) Sin[x] Subscript[[Phi], 0, 1][t] + E^(-(1/2) x^2 Subscript[K, 1][t]) x Cos[x] Subscript[K, 1][t] Subscript[[Phi], 0, 1][t] Meaning that it re-runs the initial definition, and so uses the chain rule. How can I prevent this behavior, "freeze" the definition of the function and just getting its formal value at a point (for example, when z=eta[x,t]) ? Thanks a lot
5 Replies
Sort By:
Posted 10 years ago
 Oh, I'm sorry, I wasn't aware of those possibilities.So once again. Here is a sample code :  ClearAll[Eta, CapitalPhi, Phi, Delta, OrderDev, x, z, t, i, n, K, dxphi, dzphi, dxphis, dzphis]; OrderDev = 1; i = 0; Eta[x_, t_] := Sum [K[n][t] x^(2 n)/(2 n)!, {n, 0, OrderDev}]; Delta[ z_, t_] := z - K[t]; CapitalPhi[x_, z_, t_] := -Sum [Phi[n][t] Cos[n x - i Pi] Exp[-n Delta[z, t]], {n, 1, OrderDev}]; dxphi[x_, z_, t_] := D[CapitalPhi[x, z, t], x]; dzphi[x_, z_, t_] := D[CapitalPhi[x, z, t], z]; dxphis[x_, t_] := dxphi[x, Eta[x, t], t]; dzphis[x_, t_] := dzphi[x, Eta[x, t], t]; Mathematica doesn't understand what I say, which shows that I'm saying it wrong. When I ask dxphi[x, z, t] It answers E^(-z + K[t]) Sin[x] Phi[t] Which is OK with me, but then, dxphis[x, t] Produces E^(-(1/2) x^2 K[t]) Sin[x] Phi[t] + E^(-(1/2) x^2 K[t]) x Cos[x] K[t] Phi[t] When I expect E^(-(1/2) x^2 K[t]) Sin[x] Phi[t] Worse, in the case of dzphis[x, t] It says General::ivar: K[t]+1/2 x^2 K[t] is not a valid variable. >> So I assume that when I say something like $g(x)= {\partial f \over \partial x}$ and then $h(x) = g(u(x))$, it keeps the memory of the definition of $g$ and gives ${\partial f \over \partial x} (u(x)) \times u'(x)$, while I was looking for ${\partial f \over \partial x}| _ {\ u(x)}$.Could you help me to define dxphis and dzphis in a proper way ?Thank you in advance for your attention.
Posted 9 years ago
 This may get you closer to what you want. dzphi[x_, z_, t_] := Module[{zz}, D[CapitalPhi[x, zz, t], zz] /. zz -> z] Now we get this. In:= dzphis[x, t] Out= E^(-(1/2) x^2 K[t]) Cos[x] Phi[t] 
Posted 9 years ago
 Yes, that's what I had discover. Thank you very much for your help. :)
Posted 10 years ago
 A quick tutorial on the code formatting tools is in http://community.wolfram.com/groups/-/m/t/270507. Subscripts in executable code need help. See the notebook attachment SubscriptedVariables101.nb in thread http://community.wolfram.com/groups/-/m/t/237039 for suggestions.
Posted 10 years ago
 Could you edit your post to make use of the formatting tools (in particular the code sample tool) so that your code is more readable and so that some special characters are not dropped? That will make it so that folks can play with it by copying and pasting into Mathematica and advise you.--David