UnapplyFuncs := proc( functions::Or(set,list)({name,function}=algebraic), \$) local fcn, output: description "Given a set of equalities with names or functions on the LHS and algebraic functions on the RHS, unapply any functions on the LHS": output := []: for fcn in functions do # Get arguments of fcn [op(lhs(fcn))]: # Unapply function 'op(0,lhs(fcn))' = unapply(rhs(fcn), %): # Store results output := [op(output), %]: end do: return output: end proc: EvalSolutions := proc( exprs, solutions::Or(set,list)({name,function}=algebraic), \$) local eval_fcns: description "Evaluates `exprs` using `solutions`": # Unapply solutions to get them in functional form eval_fcns := UnapplyFuncs(solutions): # Insert `solutions` to be evaluated eval['recurse'](convert(exprs,D), eval_fcns): eval(exprs, solutions): return %: end proc: ## Prep memory usage pdes := [diff(diff(phi(t,x,z),x),x)+diff(diff(phi(t,x,z),z),z) = 0, eval(diff(phi(t,x,z),z),{z = -infinity}) = 0, diff(eta(t,x),t)+diff(eta(t,x),x)*D[2](phi) (t,x,0)-D[3](phi)(t,x,0)+(diff(eta(t,x),x)*D[2,3](phi)(t,x,0)-D[3,3](phi)(t,x,0))*eta(t,x) = 0, P(t,x)+eta(t,x)+D[1](phi)(t,x,0)+1/2*D[2](phi)(t,x,0) ^2+1/2*D[3](phi)(t,x,0)^2+(D[1,3](phi)(t,x,0)+D[2](phi)(t,x,0)*D[2,3](phi)(t,x,0)+D[3](phi)(t,x,0)*D[3,3](phi)(t,x,0))*eta(t,x) = 0]: sols := [eta(t,x) =(4*A1^2*epsilon^2*k*cos(2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*cos(k*x)^2-4*A1^2*epsilon^2*k*sin(2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*sin(k*x)*cos(k*x)-2*A1^2*epsilon^2*k*cos(2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)+2*A1*epsilon*cos(k*x)*cos(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)-2*A1*epsilon*sin(k*x)*sin(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2))/exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2)), phi(t,x,z) =(A1^2*2^(1/2)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))*cos(psi__p)*epsilon^2*k^3*p+2^(1/2)*epsilon*A1*k^2*cos(psi__p)*p*exp(k*z)*cos(k*x)*cos(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)-2^(1/2)*epsilon*A1*k^2*cos(psi__p)*p*exp(k*z)*sin(k*x)*sin(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)-2^(1/2)*epsilon^2*A1^2*cos(psi__p)*k^3*p-A1^2*2^(1/2)*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))*epsilon^2*k^2-2^(1/2)*epsilon*A1*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)*k*exp(k*z)*cos(k*x)*cos(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)+2^(1/2)*epsilon*A1*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)*k*exp(k*z)*sin(k*x)*sin(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)-2^(1/2)*epsilon*A1*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*(-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*exp(k*z)*cos(k*x)*sin(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)-2^(1/2)*epsilon*A1*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*(-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*exp(k*z)*sin(k*x)*cos(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)+2^(1/2)*epsilon^2*A1^2*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)*k^2+A1^2*2^(1/2)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))*epsilon^2*k^2+2^(1/2)*epsilon*A1*k*exp(k*z)*cos(k*x)*cos(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)-2^(1/2)*epsilon*A1*k*exp(k*z)*sin(k*x)*sin(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)-2^(1/2)*epsilon^2*A1^2*k^2)/exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))/(-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)/k,P(t,x) = (-4*A1^2*k^2*p*epsilon^2*sin(2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*sin(psi__p)*cos(k*x)^2-4*A1^2*k^2*p*epsilon^2*cos(psi__p)*sin(2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*sin(k*x)*cos(k*x)+4*A1^2*k^2*p*epsilon^2*cos(psi__p)*cos(2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*cos(k*x)^2-4*A1^2*k^2*p*epsilon^2*cos(2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*sin(psi__p)*sin(k*x)*cos(k*x)+2*A1^2*k^2*p*epsilon^2*sin(2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*sin(psi__p)-2*A1^2*k^2*p*epsilon^2*cos(psi__p)*cos(2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)+2*A1*k*p*epsilon*cos(psi__p)*cos(k*x)*cos(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)-2*A1*k*p*epsilon*cos(k*x)*sin(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*sin(psi__p)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)-2*A1*k*p*epsilon*sin(k*x)*cos(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*sin(psi__p)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2)-2*A1*k*p*epsilon*cos(psi__p)*sin(k*x)*sin(1/2*2^(1/2)*(cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+k)^(1/2)*t)*exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))^(1/2))/exp((-cos(psi__p)*k^2*p+k*(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)-k)^(1/2)*t*2^(1/2))]: assumptions := {A1::real, epsilon::positive, k::positive, p::positive, t::real, x::real, z::negative, 0 < psi__p, psi__p < 1/2*Pi}: # Evaluate pdes using solutions simplified_pdes := EvalSolutions([pdes[4]], sols): ## Actual computation 1/2*A1/exp((-k^2*p*exp(I*psi__p)-k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)-2*k)^(1/2)*t)^(1/2)*k*epsilon*p*exp(I*k*x)*exp(1/2*I*(k^2*p*exp(I*psi__p)+k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)+2*k)^(1/2)*t)*exp(I*psi__p)-1/2*A1/exp((-k^2*p*exp(I*psi__p)-k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)-2*k)^(1/2)*t)^(1/2)*k*epsilon*p*exp(I*k*x)*exp(1/2*I*(k^2*p*exp(I*psi__p)+k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)+2*k)^(1/2)*t)/exp(I*psi__p)-1/2*A1/exp((-k^2*p*exp(I*psi__p)-k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)-2*k)^(1/2)*t)^(1/2)*k*epsilon*p/exp(I*k*x)*exp(-1/2*I*(k^2*p*exp(I*psi__p)+k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)+2*k)^(1/2)*t)*exp(I*psi__p)+1/2*A1/exp((-k^2*p*exp(I*psi__p)-k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)-2*k)^(1/2)*t)^(1/2)*k*epsilon*p/exp(I*k*x)*exp(-1/2*I*(k^2*p*exp(I*psi__p)+k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)+2*k)^(1/2)*t)/exp(I*psi__p)-1/2*I*A1/exp((-k^2*p*exp(I*psi__p)-k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)-2*k)^(1/2)*t)^(1/2)*epsilon*exp(I*k*x)*exp(1/2*I*(k^2*p*exp(I*psi__p)+k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)+2*k)^(1/2)*t)*(-k^2*p^2*exp(I*psi__p)^2+2*k^2*p^2-k^2*p^2/exp(I*psi__p)^2)^(1/2)+1/2*I*A1/exp((-k^2*p*exp(I*psi__p)-k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)-2*k)^(1/2)*t)^(1/2)*epsilon/exp(I*k*x)*exp(-1/2*I*(k^2*p*exp(I*psi__p)+k^2*p/exp(I*psi__p)+2*k*(k^2*p^2+k*p*exp(I*psi__p)+k*p/exp(I*psi__p)+1)^(1/2)+2*k)^(1/2)*t)*(-k^2*p^2*exp(I*psi__p)^2+2*k^2*p^2-k^2*p^2/exp(I*psi__p)^2)^(1/2) = 0: #gc(): simplify(%,symbolic) assuming op(assumptions): print(%):