Appropriately thank a supervisor for giving you a chance when you actually failed? In general:

What is the proper manner in which to thank a supervisor for allowing you to take a really long shot? I am talking about when a professor (supervisor) who did not really know you decides to give you a chance, even though there is clearly a very low probability of success. Especially in the case where the supervisor invested significant physical resources and/or their time and you still failed to accomplish the goal (in this case research result). I am looking for a formal and appropriate way to convey my gratitude to the professor for taking the risk. Again this is in the context where you have specifically failed to reach the goal and cost the supervisor in question a good deal of resources in the process. Is it even proper to convey gratitude at this juncture for giving you an outside shot at tremendous opportunity? Or should I just be extremely apologetic?
"Thanks for the opportunity" is almost always appropriate and welcome.

As far as "apologetic" goes, I'd think on why the goal wasn't reached. Some research projects are known to be long shots before they're begun and failure, while obviously not desired, is not an unforeseen outcome. Sometimes outside events beyond anyone's control torpedo things. If this is the "flavor" of your situation, then I don't necessarily think abject apologies are called for, though you can certainly commiserate with others involved on how things turned out. Sometimes research just doesn't pan out, and good research supervisors understand that you can't hit if you don't swing.

On the other hand, when I've been part of projects that failed in whole or part due to things I did or didn't do, I've tried to make sure the supervisor involved knows that at least I learned from the experience and that I had an idea of how I would do things differently in similar circumstances should they arise. Really, this is a valuable response in either case. Especially, though, if you hope to have future research opportunities with this supervisor, I'd make sure this is understood.