forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request lcompilers#2387 from anutosh491/const_E
Implemented symbolic constant E
- Loading branch information
Showing
5 changed files
with
133 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from sympy import Symbol, E, log, exp | ||
from lpython import S | ||
|
||
def main0(): | ||
# Define symbolic variables | ||
x: S = Symbol('x') | ||
y: S = Symbol('y') | ||
|
||
# Assign E to the variable x | ||
x = E | ||
|
||
# Check if x is equal to E | ||
assert x == E | ||
|
||
# Perform some symbolic operations | ||
z: S = x + y | ||
|
||
# Check if z is equal to E + y | ||
assert z == E + y | ||
|
||
# Check if x is not equal to 2E + y | ||
assert x != S(2) * E + y | ||
|
||
# Evaluate some mathematical expressions | ||
expr1: S = log(E) | ||
expr2: S = exp(S(1)) | ||
|
||
# Check the results | ||
assert expr1 == S(1) | ||
assert expr2 == E ** S(1) | ||
|
||
# Print the results | ||
print("x =", x) | ||
print("z =", z) | ||
print("log(E) =", expr1) | ||
print("exp(1) =", expr2) | ||
|
||
|
||
main0() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters