All tickets are Super Off-Peak Returns (in this case - travel after 09:30, outbound within 1 day, return within 1 month) unless otherwise stated.
Newcastle to Edinburgh - £32.00
Newcastle to Berwick upon Tweed - £14.85
and Berwick upon Tweed to Edinburgh - £14.35: total of £29.20
Newcastle to Dunbar Direct - £18.40 and Dunbar to Edinburgh Cheap Day Return (outward not before 05:00, outward and return journies on same day) - £7.15: total of £25.55
Obviously you would have to make sure that your trains stopped at these stations. Some more experienced members of the forum may be able to give better advice.