I'm trying to find u(x,y)
such that
$$ 0=-axy+bx^2-cyu_y-du_x^2 $$
using the ansatz
$$ u(x,y)=1/2\begin{pmatrix}x \\ y\end{pmatrix}^T\begin{pmatrix} A_{11} & A_{12} \\ A_{12} & A_{22} \end{pmatrix}\begin{pmatrix}x \\ y\end{pmatrix}. $$
In fact, this is only a simple example of what I am trying to do, which I can solve by hand:
$$ A_{11} = \sqrt{b/d}\\ A_{12} = \frac{-a}{c+2\sqrt{bd}}\\ A_{22} = -\frac{d}{c}\frac{a^2}{(c+2\sqrt{b/d})^2} $$
I could not reproduce this solution in Mathematica. I am very new to Mathematica and I feel like the little bit I could do is already awfully inelegant:
u[x_,y_]:=1/2*{x,y}.({{A11,A12},{A12,A22}}.{x,y})
dx=D[u[x,y],x]
dy=D[u[x,y],y]
equation=-Pi*x*y+x^2-y*dy-dx^2==0
SolveAlways[equation,{x,y}]
As you can see, I replaced a
by \pi
and set b=c=d=1
.
These commands returns the solution I am after in that special case (as well as a solution with A_{11}<0
, which I'd like to exclude, but that's a different story).
If I replace \pi
by a
and use SolveAlways[equation,{x,y,a}]
Mathematica returns an empty set.
Things I'd like to be able to do:
- Define the PDE for general functions, and then insert the specific ansatz, instead of using the specific ansatz directly.
- Solve for the coefficients of the quadratic ansatz, in the case of general coefficients
a,b,c,d
. - Define general quadratic ansatz functions in higher dimensions, without typing out the symmetric matrix by hand
- Learn about any other things to make my code more idiomatic.
PS: Could anyone tell me why the site keeps telling me that "Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button..."? The only way I was able to post this question was to replace all math blocks by code blocks. I apologize for that. Before this replacement the question was displayed properly in the preview window, except that line breaks in math mode were ignored.