Sorry, I correct the last sentence. Maybe finding the maximizer parameter does not need to solve this equation and you know better way to do that. ----- Original Message ----- From: Amireh Mousavi (amireh.mousavi@math.iut.ac.ir) Date: 10/08/97 20:20 To: firedrake@imperial.ac.uk Subject: Re: [firedrake] Solving nonlinear algebraic equation Dear Lawrence, I think it's better I explain why I need to solve this kind of equation. In fact, the main goal is finding parameter alpha which maximizes some expression like as (A_alpha : A - f_alpha) which A_alpha and A are matrices, f_alpha is scalar valued and A_alpha , f_alpha depend on parameter alpha( 0<=alpha<2Pi). About the first suggestion (computing Jacobian), it just computes one root and since I need to find maximizer so maybe doesn't find it. The second suggestion didn't work in my code. Maybe solving this equation is not needed to find the maximizer parameter and you know better solution. Thank you. ----- Original Message ----- From: Lawrence Mitchell (wencel@gmail.com) Date: 09/08/97 18:35 To: firedrake (firedrake@imperial.ac.uk) Subject: Re: [firedrake] Solving nonlinear algebraic equation Dear Amireh,
On 30 Oct 2018, at 17:04, Amireh Mousavi <amireh.mousavi@math.iut.ac.ir> wrote:
Dear Firedrake team,
I'm trying to solve Hamilton-Jacobi-Bellman equation. It is a fully nonlinear equation, so after linearization, in each iteration in first we need to determine a parameter which is obtained from solving nonlinear algebraic equation and after that we solve the linear PDE. How can I solve nonlinear algebraic equation in Firedrake?
Consider the simple example:
mesh = UnitSquareMesh(4, 4)
R = FunctionSpace(mesh, "R", 0)
Ralpha = Function(R)
alpha = variable(Ralpha)
A_alpha = as_tensor([[cos(alpha) , -sin(alpha)] , [sin(alpha) , cos(alpha)]])
A = Constant([[20 ,1] , [1 , 0.1]])
A_alphaA = inner(A_alpha , A)
#dA_alphaA = solve(diff(A_alphaA , alpha ), alpha)
How can I solve "diff(A_alphaA , alpha)=0" in Firedrake ?
If this is actually the thing you want to solve, that is, a single-variable nonlinear problem, I would be tempted to just write out the Jacobian for this problem "by hand" and then use one of the nonlinear iterations in scipy to minimise it. You could pose this as a variational problem over R, since I think in that case the directional derivative and the normal "diff" derivative match up. So you could say: solve(derivative(A_alphaA, alpha) == 0, alpha) But if you have to do this a lot, that won't be the most efficient way of inverting the 1x1 Jacobian. Does that help? Cheers, Lawrence _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake