How to resolve the algorithm Tropical algebra overloading step by step in the R programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Tropical algebra overloading step by step in the R programming language
Table of Contents
Problem Statement
In algebra, a max tropical semiring (also called a max-plus algebra) is the semiring (ℝ ∪ -Inf, ⊕, ⊗) containing the ring of real numbers ℝ augmented by negative infinity, the max function (returns the greater of two real numbers), and addition. In max tropical algebra, x ⊕ y = max(x, y) and x ⊗ y = x + y. The identity for ⊕ is -Inf (the max of any number with -infinity is that number), and the identity for ⊗ is 0. Show that 2 ⊗ -2 is 0, -0.001 ⊕ -Inf is -0.001, 0 ⊗ -Inf is -Inf, 1.5 ⊕ -1 is 1.5, and -0.5 ⊗ 0 is -0.5. where ⊗ has precedence over ⊕. Demonstrate that 5 ⊗ (8 ⊕ 7) equals 5 ⊗ 8 ⊕ 5 ⊗ 7.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Tropical algebra overloading step by step in the R programming language
Source code in the r programming language
"%+%"<- function(x, y) max(x, y)
"%*%" <- function(x, y) x + y
"%^%" <- function(x, y) {
stopifnot(round(y) == y && y > 0)
x * y
}
cat("2 %*% -2 ==", 2 %*% -2, "\n")
cat("-0.001 %+% -Inf ==", 0.001 %+% -Inf, "\n")
cat("0 %*% -Inf ==", 0 %*% -Inf, "\n")
cat("1.5 %+% -1 ==", 1.5 %+% -1, "\n")
cat("-0.5 %*% 0 ==", -0.5 %*% 0, "\n")
cat("5^7 ==", 5 %^% 7, "\n")
cat("5 %*% (8 %+% 7)) ==", 5 %*% (8 %+% 7), "\n")
cat("5 %*% 8 %+% 5 %*% 7 ==", (5 %*% 8) %+% (5 %*% 7), "\n")
cat("5 %*% 8 %+% 5 %*% 7 == 5 %*% (8 %+% 7))", 5 %*% (8 %+% 7) == (5 %*% 8) %+% (5 %*% 7), "\n")
You may also check:How to resolve the algorithm Filter step by step in the OCaml programming language
You may also check:How to resolve the algorithm Function definition step by step in the Fexl programming language
You may also check:How to resolve the algorithm Range expansion step by step in the Lasso programming language
You may also check:How to resolve the algorithm Pinstripe/Display step by step in the Go programming language
You may also check:How to resolve the algorithm Factorial step by step in the WDTE programming language