# [petsc-users] KSPBuildSolution

Barry Smith bsmith at mcs.anl.gov
Fri Feb 18 08:23:29 CST 2011

```  I don't know how to handle the f'(1) = b. I was always taught to first introduce new variables to reduce the problem to a first order equation. For example let g = f'  and the new
problem is F(f,g,g') = 0 with the additional equations g = f' now there are no second derivatives.

Barry

On Feb 17, 2011, at 5:01 PM, Juha Jäykkä wrote:

>>  On boundary points where you want your mathematical solution x*| at that
>> point  = a you need to use for your coded function f(x) = x -  a. Its
>> derivative is f'(x) = 1 which is nonzero is fine. If the derivative at
>> other points is order K you can use f(x) = K*(x - a)  so the derivate at
>> that point is K.
>
> I am not sure, I understood this. Just to make sure there is no confusion with
> the notation, my unknown function be called f and my independent variable x
> and f is defined for 0 <= x <= 1. I use f' for the derivative of f. The
> nonlinear equation I want to solve is F(f,f',f'',x)=0.
>
> So, if I want f(1) = a and f'(1) = b, should I set the F(1) = b*(f-a) in the
> code? Will that not give 0 residual when f(1)=a regardless of it derivative?
>
> Or, alternatively, is my approach totally wrong to begin with? I took a step
> back and started to work with
>
> r f''/f - r (f'/f)^2 + f'/f = 0
>
> only and cannot get it to converge any more than my actual problem. Now, for
> this I even know the general solution, so it should be easy to solve this for
> f(1)=1, f'(1)=2 (or 1/2, but that has singular derivative at 0, so perhaps it
> is not a good example).
>
> Cheers,
> Juha
>
> --
> 		 -----------------------------------------------
> 		| Juha Jäykkä, juhaj at iki.fi			|
> 		| http://www.maths.leeds.ac.uk/~juhaj		|
> 		 -----------------------------------------------

```