# R code that gives results like Wolfram Alpha for the expectation of a function of a random variable? [closed]

When I ask Wolfram Alpha to calculate $$E[f(X)]$$ where $$f(x) = e^{-x^2}$$ and $$X \sim \mathcal{N}(1,4)$$, it gives the result $$E[f(X)] = \frac{1}{3\sqrt{e}} \approx 0.29828,$$ and the following plot which appears to be based on taking a number of simulations: How can I generate the same type of plot using R?

library(ggplot2)
{"ft_lang_label":"__label__en","ft_lang_prob":0.8331748,"math_prob":0.9999727,"size":312,"snap":"2021-31-2021-39","text_gpt3_token_len":102,"char_repetition_ratio":0.055194806,"word_repetition_ratio":0.0,"special_character_ratio":0.3653846,"punctuation_ratio":0.08450704,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":1.0000088,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,1,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-08-03T17:40:46Z\",\"WARC-Record-ID\":\"<urn:uuid:86ce8f95-e396-4a6e-a3cd-0d6c9cafd20e>\",\"Content-Length\":\"148542\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c3e22c07-4d91-4abf-93f4-aacea9297ae0>\",\"WARC-Concurrent-To\":\"<urn:uuid:746d3caa-b3bb-47af-b8f6-19cc084f43d6>\",\"WARC-IP-Address\":\"151.101.65.69\",\"WARC-Target-URI\":\"https://datascience.stackexchange.com/questions/84976/r-code-that-gives-results-like-wolfram-alpha-for-the-expectation-of-a-function-o\",\"WARC-Payload-Digest\":\"sha1:A4FFHULGLERWDWZMZZEP6AOGK3QHYOSG\",\"WARC-Block-Digest\":\"sha1:CHY6KESKPVIEHM5BP6BDSRI2LMY52C7U\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046154466.61_warc_CC-MAIN-20210803155731-20210803185731-00242.warc.gz\"}"}