-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathsymbolics_12.py
70 lines (50 loc) · 1.37 KB
/
symbolics_12.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from sympy import Symbol, E, log, exp, oo
from lpython import S
def main0():
# Testing out symbolic constants like E, oo etc
# 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)
# Test symbolic infinity constant
inf: S = oo
# Check if inf is equal to oo
assert inf == oo
# Perform some symbolic operations with oo
z = x + inf
# Check if z is equal to x + oo
assert z == x + oo
# Check if x is not equal to 2 * oo + y
assert x != S(2) * oo + y
# Evaluate some mathematical expressions with oo
expr1 = log(oo)
expr2 = exp(oo)
# Check the results
assert expr1 == oo
assert expr2 == oo
# Print the results
print("inf = ", inf)
print("z = ", z)
print("log(oo) = ", expr1)
print("exp(oo) = ", expr2)
main0()