According to Google Maps, driving from John O'Groats to Land's End is about 1400km.
The cost of construction for high-speed rail in France (admittedly several years ago) was about 10 million euros per km - or at current exchange rates, about £9m.
That would make the total cost approximately £12.6bn.
Now, of course the rail route wouldn't follow road routes, and there has been lots of inflation, and Britain might just be more expensive than France. No doubt the cost of dealing with the militant RMT members who will be involved in the construction pushes up the price in Britain too.
Counter to that, though, construction should have become cheaper as technology improves.
I think £20bn sounds more or less reasonable, based on the above. You are of course right, though - it is difficult to come up with a fair value. £38bn sounds too much instinctively to me though. The £18bn difference would be better spent in cutting taxes, or just paying off some debt.