Skip to content
-
Calculate exponential of a number in R Programming - exp() Function
Last Updated :
01 Jun, 2020
exp()
function in
R Language is used to calculate the power of e i.e. e^y or we can say exponential of y. The value of e is approximately equal to 2.71828…..
Syntax: exp(y)
Parameters:
y: It is any valid R number either positive or negative.
Returns: Floating point number by calculating e^y.
Example 1:
Python3
# R program to calculate exp value
# Using exp() method
answer1 <- exp(4)
answer2 <- exp(-3)
answer3 <- exp(0.0)
print(answer1)
print(answer2)
print(answer3)
Output:
54.59815
0.04978707
1
Example 2:
Python3
# R program to calculate exp value
# Using exp() method
answer1 <- exp(c(pi, exp(1)))
print(answer1)
Output:
23.14069 15.15426
Similar Reads
Compute the Exponential minus 1 of a Number in R Programming - expm1() Function expm1() function in R Language is used to compute exponential minus 1 i.e, exp()-1. Syntax: expm1(x) Parameters: a, b: number or number vector Example 1: Python3 # R program to illustrate # expm1 function # Calling the expm1() function expm1(4) # e5 -1 expm1(10) expm1(15) Output: [1] 53.59815 [1] 22
1 min read
Calculate Inverse cosine of a value in R Programming - acos() Function acos() function in R Language is used to calculate the inverse cosine value of the numeric value passed to it as argument. Syntax: acos(x) Parameter: x: Numeric value Example 1: Python3 1== # R code to calculate inverse cosine of a value # Assigning values to variables x1 <- -1 x2 <- 0.5 # Usi
1 min read
Calculate Factorial of a value in R Programming - factorial() Function The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. It is defined as: n! = n à (n - 1) à (n - 2) à ... à 2 à 1For example 5! = 5 à 4 à 3 à 2 à 1 = 1200! is defined to be 1.Factorials have important applications in mathematics, co
3 min read
Calculate Cumulative Sum of a Numeric Object in R Programming - cumsum() Function The cumulative sum can be defined as the sum of a set of numbers as the sum value grows with the sequence of numbers. cumsum() function in R Language is used to calculate the cumulative sum of the vector passed as argument. Syntax: cumsum(x)Â Parameters:Â x: Numeric Object Example 1:Â Python3 # R pr
1 min read
Calculate Cumulative Product of a Numeric Object in R Programming â cumprod() Function cumprod() function in R Language is used to calculate the cumulative product of the vector passed as argument. Syntax: cumprod(x) Parameters: x: Numeric Object Example 1: Python3 1== # R program to illustrate # the use of cumprod() Function # Calling cumprod() Function cumprod(1:4) cumprod(-1:-6) Ou
1 min read
Calculate Hyperbolic cosine of a value in R Programming - cosh() Function cosh() function in R Language is used to calculate the hyperbolic cosine value of the numeric value passed to it as the argument. Syntax: cosh(x)Parameter: x: Numeric value Example 1:  Python3 # R code to calculate cosine of a value # Assigning values to variables x1 <- 90 x2 <- 30 # Using c
1 min read
Convert a Numeric Object to Character in R Programming - as.character() Function as.character() function in R Language is used to convert a numeric object to character object. Syntax: as.character(x) Parameters: x: Numeric Object Example 1: Python3 1== # R program to convert a numeric object # to character object # Calling as.character() function as.character(1) as.character(2 +
1 min read
Calculate sine of a value in R Programming - sin() Function sin() function in R Language is used to calculate the sine value of the numeric value passed to it as argument. Syntax: sin(x) Parameter: x: Numeric value Example 1: Python3 1== # R code to calculate sine of a value # Assigning values to variables x1 <- -90 x2 <- -30 # Using sin() Function sin
1 min read
Calculate tangent of a value in R Programming - tan() Function tan() function in R Language is used to calculate the tangent of the numeric value passed to it as argument. Syntax: tan(x) Parameter: x: Numeric value Example 1: Python3 1== # R code to calculate tangent of a value # Assigning values to variables x1 <- -90 x2 <- -30 # Using tan() Function tan
1 min read
Exponential Distribution in R Programming - dexp(), pexp(), qexp(), and rexp() Functions The Exponential Distribution is a continuous probability distribution that models the time between independent events occurring at a constant average rate. It is widely used in fields like reliability analysis, queuing theory, and survival analysis. The exponential distribution is a special case of
5 min read
top_of_element && top_of_screen articleRecommendedTop && top_of_screen articleRecommendedBottom)) {
if (!isfollowingApiCall) {
isfollowingApiCall = true;
setTimeout(function(){
if (loginData && loginData.isLoggedIn) {
if (loginData.userName !== $('#followAuthor').val()) {
is_following();
} else {
$('.profileCard-profile-picture').css('background-color', '#E7E7E7');
}
} else {
$('.follow-btn').removeClass('hideIt');
}
}, 3000);
}
}
});
}
$(".accordion-header").click(function() {
var arrowIcon = $(this).find('.bottom-arrow-icon');
arrowIcon.toggleClass('rotate180');
});
});
window.isReportArticle = false;
function report_article(){
if (!loginData || !loginData.isLoggedIn) {
const loginModalButton = $('.login-modal-btn')
if (loginModalButton.length) {
loginModalButton.click();
}
return;
}
if(!window.isReportArticle){
//to add loader
$('.report-loader').addClass('spinner');
jQuery('#report_modal_content').load(gfgSiteUrl+'wp-content/themes/iconic-one/report-modal.php', {
PRACTICE_API_URL: practiceAPIURL,
PRACTICE_URL:practiceURL
},function(responseTxt, statusTxt, xhr){
if(statusTxt == "error"){
alert("Error: " + xhr.status + ": " + xhr.statusText);
}
});
}else{
window.scrollTo({ top: 0, behavior: 'smooth' });
$("#report_modal_content").show();
}
}
function closeShareModal() {
const shareOption = document.querySelector('[data-gfg-action="share-article"]');
shareOption.classList.remove("hover_share_menu");
let shareModal = document.querySelector(".hover__share-modal-container");
shareModal && shareModal.remove();
}
function openShareModal() {
closeShareModal(); // Remove existing modal if any
let shareModal = document.querySelector(".three_dot_dropdown_share");
shareModal.appendChild(Object.assign(document.createElement("div"), { className: "hover__share-modal-container" }));
document.querySelector(".hover__share-modal-container").append(
Object.assign(document.createElement('div'), { className: "share__modal" }),
);
document.querySelector(".share__modal").append(Object.assign(document.createElement('h1'), { className: "share__modal-heading" }, { textContent: "Share to" }));
const socialOptions = ["LinkedIn", "WhatsApp","Twitter", "Copy Link"];
socialOptions.forEach((socialOption) => {
const socialContainer = Object.assign(document.createElement('div'), { className: "social__container" });
const icon = Object.assign(document.createElement("div"), { className: `share__icon share__${socialOption.split(" ").join("")}-icon` });
const socialText = Object.assign(document.createElement("span"), { className: "share__option-text" }, { textContent: `${socialOption}` });
const shareLink = (socialOption === "Copy Link") ?
Object.assign(document.createElement('div'), { role: "button", className: "link-container CopyLink" }) :
Object.assign(document.createElement('a'), { className: "link-container" });
if (socialOption === "LinkedIn") {
shareLink.setAttribute('href', `https://www.linkedin.com/sharing/share-offsite/?url=${window.location.href}`);
shareLink.setAttribute('target', '_blank');
}
if (socialOption === "WhatsApp") {
shareLink.setAttribute('href', `https://api.whatsapp.com/send?text=${window.location.href}`);
shareLink.setAttribute('target', "_blank");
}
if (socialOption === "Twitter") {
shareLink.setAttribute('href', `https://twitter.com/intent/tweet?url=${window.location.href}`);
shareLink.setAttribute('target', "_blank");
}
shareLink.append(icon, socialText);
socialContainer.append(shareLink);
document.querySelector(".share__modal").appendChild(socialContainer);
//adding copy url functionality
if(socialOption === "Copy Link") {
shareLink.addEventListener("click", function() {
var tempInput = document.createElement("input");
tempInput.value = window.location.href;
document.body.appendChild(tempInput);
tempInput.select();
tempInput.setSelectionRange(0, 99999); // For mobile devices
document.execCommand('copy');
document.body.removeChild(tempInput);
this.querySelector(".share__option-text").textContent = "Copied"
})
}
});
// document.querySelector(".hover__share-modal-container").addEventListener("mouseover", () => document.querySelector('[data-gfg-action="share-article"]').classList.add("hover_share_menu"));
}
function toggleLikeElementVisibility(selector, show) {
document.querySelector(`.${selector}`).style.display = show ? "block" : "none";
}
function closeKebabMenu(){
document.getElementById("myDropdown").classList.toggle("show");
}