bvpexample <- function ( yp0 ) #*****************************************************************************80 # ## bvpexample attempts to match a boundary value problem. # # Discussion: # # The BVP is: # y''(x,y) = y^2 - 2.0 # y(0.0) = 1.0 # y(1.0) = 1.0 # Instead, we solve the IVP # z''(x,z) = z^2 - 2.0 # z(0.0) = 1.0 # z'(0.0) = yp0 # and return # value = z(1.0) - y(1.0) # # Licensing: # # Copyright 2016 James P. Howard, II # # The computer code and data files on this web page are distributed under # https://opensource.org/licenses/BSD-2-Clause, the BSD-2-Clause license. # # Modified: # # 28 March 2020 # # Author: # # Original R code by James Howard; # Modifications by John Burkardt. # # Reference: # # James Howard, # Computational Methods for Numerical Analysis with R, # CRC Press, 2017 # ISBN13: 978-1-4987-2363-3. # { source ( "/home/burkardt/public_html/r_src/eulersys/eulersys.R" ) x0 <- 0.0 y0 <- c ( y1 = 1.0, y2 = yp0 ) yn <- 1.0 odesystem <- function ( x, y ) { y1 <- y[2] y2 <- y[1]^2 - 2.0 return ( c ( y1 = y1, y2 = y2 ) ) } n = 1000 h <- 1.0 / n z <- eulersys ( odesystem, x0, y0, h, n ) value <- tail ( z$y1, 1 ) - yn return ( value ) }