jarviscore-framework 0.1.1__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. examples/autoagent_distributed_example.py +211 -0
  2. examples/custom_profile_decorator.py +134 -0
  3. examples/custom_profile_wrap.py +168 -0
  4. examples/customagent_distributed_example.py +362 -0
  5. examples/customagent_p2p_example.py +347 -0
  6. jarviscore/__init__.py +49 -36
  7. jarviscore/adapter/__init__.py +15 -9
  8. jarviscore/adapter/decorator.py +23 -19
  9. jarviscore/adapter/wrapper.py +303 -0
  10. jarviscore/cli/scaffold.py +1 -1
  11. jarviscore/cli/smoketest.py +3 -2
  12. jarviscore/core/agent.py +44 -1
  13. jarviscore/core/mesh.py +196 -35
  14. jarviscore/data/examples/autoagent_distributed_example.py +211 -0
  15. jarviscore/data/examples/customagent_distributed_example.py +362 -0
  16. jarviscore/data/examples/customagent_p2p_example.py +347 -0
  17. jarviscore/docs/API_REFERENCE.md +264 -51
  18. jarviscore/docs/AUTOAGENT_GUIDE.md +198 -0
  19. jarviscore/docs/CONFIGURATION.md +35 -21
  20. jarviscore/docs/CUSTOMAGENT_GUIDE.md +415 -0
  21. jarviscore/docs/GETTING_STARTED.md +106 -13
  22. jarviscore/docs/TROUBLESHOOTING.md +144 -6
  23. jarviscore/docs/USER_GUIDE.md +138 -361
  24. jarviscore/orchestration/engine.py +20 -8
  25. jarviscore/p2p/__init__.py +10 -0
  26. jarviscore/p2p/coordinator.py +129 -0
  27. jarviscore/p2p/messages.py +87 -0
  28. jarviscore/p2p/peer_client.py +576 -0
  29. jarviscore/p2p/peer_tool.py +268 -0
  30. {jarviscore_framework-0.1.1.dist-info → jarviscore_framework-0.2.0.dist-info}/METADATA +60 -54
  31. jarviscore_framework-0.2.0.dist-info/RECORD +132 -0
  32. {jarviscore_framework-0.1.1.dist-info → jarviscore_framework-0.2.0.dist-info}/WHEEL +1 -1
  33. {jarviscore_framework-0.1.1.dist-info → jarviscore_framework-0.2.0.dist-info}/top_level.txt +1 -0
  34. test_logs/code_registry/functions/data_generator-558779ed_560ebc37.py +7 -0
  35. test_logs/code_registry/functions/data_generator-5ed3609e_560ebc37.py +7 -0
  36. test_logs/code_registry/functions/data_generator-66da0356_43970bb9.py +25 -0
  37. test_logs/code_registry/functions/data_generator-7a2fac83_583709d9.py +36 -0
  38. test_logs/code_registry/functions/data_generator-888b670f_aa235863.py +9 -0
  39. test_logs/code_registry/functions/data_generator-9ca5f642_aa235863.py +9 -0
  40. test_logs/code_registry/functions/data_generator-bfd90775_560ebc37.py +7 -0
  41. test_logs/code_registry/functions/data_generator-e95d2f7d_aa235863.py +9 -0
  42. test_logs/code_registry/functions/data_generator-f60ca8a2_327eb8c2.py +29 -0
  43. test_logs/code_registry/functions/mathematician-02adf9ee_958658d9.py +19 -0
  44. test_logs/code_registry/functions/mathematician-0706fb57_5df13441.py +23 -0
  45. test_logs/code_registry/functions/mathematician-153c9c4a_ba59c918.py +83 -0
  46. test_logs/code_registry/functions/mathematician-287e61c0_41daa793.py +18 -0
  47. test_logs/code_registry/functions/mathematician-2967af5a_863c2cc6.py +17 -0
  48. test_logs/code_registry/functions/mathematician-303ca6d6_5df13441.py +23 -0
  49. test_logs/code_registry/functions/mathematician-308a4afd_cbf5064d.py +73 -0
  50. test_logs/code_registry/functions/mathematician-353f16e2_0968bcf5.py +18 -0
  51. test_logs/code_registry/functions/mathematician-3c22475a_41daa793.py +17 -0
  52. test_logs/code_registry/functions/mathematician-5bac1029_0968bcf5.py +18 -0
  53. test_logs/code_registry/functions/mathematician-640f76b2_9198780b.py +19 -0
  54. test_logs/code_registry/functions/mathematician-752fa7ea_863c2cc6.py +17 -0
  55. test_logs/code_registry/functions/mathematician-baf9ef39_0968bcf5.py +18 -0
  56. test_logs/code_registry/functions/mathematician-bc8b2a2f_5df13441.py +23 -0
  57. test_logs/code_registry/functions/mathematician-c31e4686_41daa793.py +18 -0
  58. test_logs/code_registry/functions/mathematician-cc84c84c_863c2cc6.py +17 -0
  59. test_logs/code_registry/functions/mathematician-dd7c7144_9198780b.py +19 -0
  60. test_logs/code_registry/functions/mathematician-e671c256_41ea4487.py +74 -0
  61. test_logs/code_registry/functions/report_generator-1a878fcc_18d44bdc.py +47 -0
  62. test_logs/code_registry/functions/report_generator-25c1c331_cea57d0d.py +35 -0
  63. test_logs/code_registry/functions/report_generator-37552117_e711c2b9.py +35 -0
  64. test_logs/code_registry/functions/report_generator-bc662768_e711c2b9.py +35 -0
  65. test_logs/code_registry/functions/report_generator-d6c0e76b_5e7722ec.py +44 -0
  66. test_logs/code_registry/functions/report_generator-f270fb02_680529c3.py +44 -0
  67. test_logs/code_registry/functions/text_processor-11393b14_4370d3ed.py +40 -0
  68. test_logs/code_registry/functions/text_processor-7d02dfc3_d3b569be.py +37 -0
  69. test_logs/code_registry/functions/text_processor-8adb5e32_9168c5fe.py +13 -0
  70. test_logs/code_registry/functions/text_processor-c58ffc19_78b4ceac.py +42 -0
  71. test_logs/code_registry/functions/text_processor-cd5977b1_9168c5fe.py +13 -0
  72. test_logs/code_registry/functions/text_processor-ec1c8773_9168c5fe.py +13 -0
  73. tests/test_01_analyst_standalone.py +124 -0
  74. tests/test_02_assistant_standalone.py +164 -0
  75. tests/test_03_analyst_with_framework.py +945 -0
  76. tests/test_04_assistant_with_framework.py +1002 -0
  77. tests/test_05_integration.py +1301 -0
  78. tests/test_06_real_llm_integration.py +760 -0
  79. tests/test_07_distributed_single_node.py +578 -0
  80. tests/test_08_distributed_multi_node.py +454 -0
  81. tests/test_09_distributed_autoagent.py +509 -0
  82. tests/test_10_distributed_customagent.py +787 -0
  83. tests/test_mesh.py +35 -4
  84. jarviscore_framework-0.1.1.dist-info/RECORD +0 -69
  85. {jarviscore_framework-0.1.1.dist-info → jarviscore_framework-0.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,36 @@
1
+ import random
2
+
3
+ def main():
4
+ # List of common words to choose from
5
+ word_pool = [
6
+ "apple", "banana", "cherry", "dragon", "elephant",
7
+ "forest", "garden", "harmony", "island", "jungle",
8
+ "kitchen", "lantern", "mountain", "notebook", "ocean",
9
+ "penguin", "quantum", "rainbow", "sunshine", "thunder",
10
+ "umbrella", "village", "whisper", "xylophone", "yellow",
11
+ "zebra", "adventure", "butterfly", "chocolate", "diamond",
12
+ "energy", "freedom", "gravity", "horizon", "imagine",
13
+ "journey", "knowledge", "library", "mystery", "nature",
14
+ "opportunity", "paradise", "question", "reflection", "serenity",
15
+ "treasure", "universe", "velocity", "wonder", "zenith"
16
+ ]
17
+
18
+ try:
19
+ # Select 5 random words from the pool
20
+ random_words = random.sample(word_pool, 5)
21
+
22
+ result = {
23
+ "description": "List of 5 randomly selected words",
24
+ "count": 5,
25
+ "words": random_words
26
+ }
27
+
28
+ return result
29
+ except Exception as e:
30
+ return {
31
+ "error": str(e),
32
+ "words": []
33
+ }
34
+
35
+ # Execute and store result
36
+ result = main()
@@ -0,0 +1,9 @@
1
+ async def main():
2
+ result = {
3
+ "products": [
4
+ {"name": "Wireless Bluetooth Headphones", "price": 79.99},
5
+ {"name": "Stainless Steel Water Bottle", "price": 24.95},
6
+ {"name": "Portable Phone Charger", "price": 34.50}
7
+ ]
8
+ }
9
+ return result
@@ -0,0 +1,9 @@
1
+ async def main():
2
+ result = {
3
+ "products": [
4
+ {"name": "Wireless Bluetooth Headphones", "price": 79.99},
5
+ {"name": "Stainless Steel Water Bottle", "price": 24.95},
6
+ {"name": "Portable Phone Charger", "price": 34.50}
7
+ ]
8
+ }
9
+ return result
@@ -0,0 +1,7 @@
1
+ async def main():
2
+ result = {
3
+ 'name': 'John Smith',
4
+ 'age': 32,
5
+ 'city': 'New York'
6
+ }
7
+ return result
@@ -0,0 +1,9 @@
1
+ async def main():
2
+ result = {
3
+ "products": [
4
+ {"name": "Wireless Bluetooth Headphones", "price": 79.99},
5
+ {"name": "Stainless Steel Water Bottle", "price": 24.95},
6
+ {"name": "Portable Phone Charger", "price": 34.50}
7
+ ]
8
+ }
9
+ return result
@@ -0,0 +1,29 @@
1
+ import random
2
+
3
+ def main():
4
+ # List of common words to choose from
5
+ word_list = [
6
+ "apple", "banana", "cherry", "dragon", "elephant",
7
+ "forest", "garden", "harmony", "island", "jungle",
8
+ "kingdom", "lantern", "mountain", "nebula", "ocean",
9
+ "phoenix", "quantum", "rainbow", "sunset", "thunder",
10
+ "umbrella", "volcano", "whisper", "xylophone", "yellow",
11
+ "zenith", "adventure", "brilliant", "cascade", "diamond",
12
+ "eclipse", "fountain", "glacier", "horizon", "infinity",
13
+ "journey", "kaleidoscope", "lighthouse", "mystery", "northern",
14
+ "orchestra", "paradise", "question", "reflection", "symphony",
15
+ "treasure", "universe", "velocity", "wanderer", "yesterday"
16
+ ]
17
+
18
+ # Select 5 random words
19
+ random_words = random.sample(word_list, 5)
20
+
21
+ result = {
22
+ "random_words": random_words,
23
+ "count": len(random_words),
24
+ "description": "A list of 5 randomly selected words"
25
+ }
26
+
27
+ return result
28
+
29
+ result = main()
@@ -0,0 +1,19 @@
1
+ async def main():
2
+ try:
3
+ import math
4
+
5
+ n = 5
6
+ factorial_result = math.factorial(n)
7
+
8
+ result = {
9
+ 'result': factorial_result,
10
+ 'calculation': f'{n}! = {factorial_result}',
11
+ 'method': 'math.factorial'
12
+ }
13
+
14
+ return result
15
+ except Exception as e:
16
+ return {
17
+ 'result': None,
18
+ 'error': str(e)
19
+ }
@@ -0,0 +1,23 @@
1
+ async def main():
2
+ try:
3
+ # Calculate sum of numbers from 1 to 100
4
+ # Using the formula: n * (n + 1) / 2
5
+ n = 100
6
+ sum_formula = n * (n + 1) // 2
7
+
8
+ # Alternative: using sum with range
9
+ sum_range = sum(range(1, 101))
10
+
11
+ result = {
12
+ 'result': sum_formula,
13
+ 'verification': sum_range,
14
+ 'method': 'Gauss formula: n*(n+1)/2',
15
+ 'n': n
16
+ }
17
+
18
+ return result
19
+ except Exception as e:
20
+ return {
21
+ 'result': None,
22
+ 'error': str(e)
23
+ }
@@ -0,0 +1,83 @@
1
+ import math
2
+
3
+ async def main():
4
+ try:
5
+ # Calculate various mathematical results
6
+ calculations = {}
7
+
8
+ # 1. Calculate the golden ratio
9
+ golden_ratio = (1 + math.sqrt(5)) / 2
10
+ calculations['golden_ratio'] = golden_ratio
11
+
12
+ # 2. Calculate e (Euler's number) using series expansion
13
+ e_approximation = sum(1 / math.factorial(n) for n in range(20))
14
+ calculations['e_approximation'] = e_approximation
15
+ calculations['e_actual'] = math.e
16
+
17
+ # 3. Calculate pi using Leibniz formula
18
+ pi_approximation = 4 * sum((-1)**n / (2*n + 1) for n in range(10000))
19
+ calculations['pi_approximation'] = pi_approximation
20
+ calculations['pi_actual'] = math.pi
21
+
22
+ # 4. Calculate factorial of 10
23
+ factorial_10 = math.factorial(10)
24
+ calculations['factorial_10'] = factorial_10
25
+
26
+ # 5. Calculate the sum of first 100 prime numbers
27
+ def is_prime(n):
28
+ if n < 2:
29
+ return False
30
+ if n == 2:
31
+ return True
32
+ if n % 2 == 0:
33
+ return False
34
+ for i in range(3, int(math.sqrt(n)) + 1, 2):
35
+ if n % i == 0:
36
+ return False
37
+ return True
38
+
39
+ primes = []
40
+ num = 2
41
+ while len(primes) < 100:
42
+ if is_prime(num):
43
+ primes.append(num)
44
+ num += 1
45
+
46
+ sum_of_primes = sum(primes)
47
+ calculations['sum_first_100_primes'] = sum_of_primes
48
+ calculations['first_10_primes'] = primes[:10]
49
+ calculations['100th_prime'] = primes[99]
50
+
51
+ # 6. Calculate Fibonacci sequence (first 20 numbers)
52
+ def fibonacci(n):
53
+ fib = [0, 1]
54
+ for i in range(2, n):
55
+ fib.append(fib[i-1] + fib[i-2])
56
+ return fib[:n]
57
+
58
+ fib_sequence = fibonacci(20)
59
+ calculations['fibonacci_20'] = fib_sequence
60
+
61
+ # 7. Calculate the area of a circle with radius 5
62
+ radius = 5
63
+ circle_area = math.pi * radius ** 2
64
+ calculations['circle_area_radius_5'] = circle_area
65
+
66
+ # 8. Calculate hypotenuse of a 3-4-5 triangle
67
+ hypotenuse = math.hypot(3, 4)
68
+ calculations['hypotenuse_3_4'] = hypotenuse
69
+
70
+ result = {
71
+ 'result': calculations,
72
+ 'status': 'success',
73
+ 'description': 'Various mathematical calculations completed successfully'
74
+ }
75
+
76
+ return result
77
+
78
+ except Exception as e:
79
+ return {
80
+ 'result': None,
81
+ 'status': 'error',
82
+ 'error': str(e)
83
+ }
@@ -0,0 +1,18 @@
1
+ import math
2
+
3
+ async def main():
4
+ try:
5
+ number = 144
6
+ square_root = math.sqrt(number)
7
+
8
+ result = {
9
+ 'result': square_root,
10
+ 'input': number,
11
+ 'operation': 'square_root'
12
+ }
13
+ return result
14
+ except Exception as e:
15
+ return {
16
+ 'result': None,
17
+ 'error': str(e)
18
+ }
@@ -0,0 +1,17 @@
1
+ async def main():
2
+ try:
3
+ calculation_result = 2 + 2
4
+ result = {
5
+ 'result': calculation_result,
6
+ 'expression': '2 + 2',
7
+ 'success': True
8
+ }
9
+ return result
10
+ except Exception as e:
11
+ result = {
12
+ 'result': None,
13
+ 'expression': '2 + 2',
14
+ 'success': False,
15
+ 'error': str(e)
16
+ }
17
+ return result
@@ -0,0 +1,23 @@
1
+ async def main():
2
+ try:
3
+ # Calculate sum of numbers from 1 to 100
4
+ # Using the formula: n * (n + 1) / 2
5
+ n = 100
6
+ sum_formula = n * (n + 1) // 2
7
+
8
+ # Alternative: using sum with range
9
+ sum_range = sum(range(1, 101))
10
+
11
+ result = {
12
+ 'result': sum_formula,
13
+ 'verification': sum_range,
14
+ 'method': 'Gauss formula: n*(n+1)/2',
15
+ 'n': n
16
+ }
17
+
18
+ return result
19
+ except Exception as e:
20
+ return {
21
+ 'result': None,
22
+ 'error': str(e)
23
+ }
@@ -0,0 +1,73 @@
1
+ import math
2
+
3
+ async def main():
4
+ try:
5
+ # Calculate various mathematical results
6
+ calculations = {}
7
+
8
+ # 1. Calculate the golden ratio
9
+ golden_ratio = (1 + math.sqrt(5)) / 2
10
+ calculations['golden_ratio'] = golden_ratio
11
+
12
+ # 2. Calculate e (Euler's number) using series expansion
13
+ e_approximation = sum(1 / math.factorial(n) for n in range(20))
14
+ calculations['e_approximation'] = e_approximation
15
+ calculations['e_actual'] = math.e
16
+
17
+ # 3. Calculate pi using Leibniz formula
18
+ pi_approximation = 4 * sum((-1)**n / (2*n + 1) for n in range(10000))
19
+ calculations['pi_approximation'] = pi_approximation
20
+ calculations['pi_actual'] = math.pi
21
+
22
+ # 4. Calculate factorial of 10
23
+ factorial_10 = math.factorial(10)
24
+ calculations['factorial_10'] = factorial_10
25
+
26
+ # 5. Calculate the sum of first 100 prime numbers
27
+ def is_prime(n):
28
+ if n < 2:
29
+ return False
30
+ for i in range(2, int(math.sqrt(n)) + 1):
31
+ if n % i == 0:
32
+ return False
33
+ return True
34
+
35
+ primes = []
36
+ num = 2
37
+ while len(primes) < 100:
38
+ if is_prime(num):
39
+ primes.append(num)
40
+ num += 1
41
+
42
+ calculations['sum_first_100_primes'] = sum(primes)
43
+ calculations['first_10_primes'] = primes[:10]
44
+
45
+ # 6. Calculate Fibonacci sequence (first 20 numbers)
46
+ def fibonacci(n):
47
+ fib = [0, 1]
48
+ for i in range(2, n):
49
+ fib.append(fib[i-1] + fib[i-2])
50
+ return fib[:n]
51
+
52
+ calculations['fibonacci_20'] = fibonacci(20)
53
+
54
+ # 7. Calculate square root of 2 (irrational number)
55
+ calculations['sqrt_2'] = math.sqrt(2)
56
+
57
+ # 8. Calculate natural logarithm of 10
58
+ calculations['ln_10'] = math.log(10)
59
+
60
+ result = {
61
+ 'result': calculations,
62
+ 'status': 'success',
63
+ 'description': 'Various mathematical calculations completed successfully'
64
+ }
65
+
66
+ return result
67
+
68
+ except Exception as e:
69
+ return {
70
+ 'result': None,
71
+ 'status': 'error',
72
+ 'error': str(e)
73
+ }
@@ -0,0 +1,18 @@
1
+ async def main():
2
+ try:
3
+ fibonacci_numbers = []
4
+ a, b = 0, 1
5
+
6
+ for _ in range(10):
7
+ fibonacci_numbers.append(a)
8
+ a, b = b, a + b
9
+
10
+ result = {
11
+ 'result': fibonacci_numbers
12
+ }
13
+ return result
14
+ except Exception as e:
15
+ return {
16
+ 'result': None,
17
+ 'error': str(e)
18
+ }
@@ -0,0 +1,17 @@
1
+ import math
2
+
3
+ async def main():
4
+ try:
5
+ number = 144
6
+ square_root = math.sqrt(number)
7
+ result = {
8
+ 'result': square_root,
9
+ 'input': number,
10
+ 'operation': 'square_root'
11
+ }
12
+ return result
13
+ except Exception as e:
14
+ return {
15
+ 'result': None,
16
+ 'error': str(e)
17
+ }
@@ -0,0 +1,18 @@
1
+ async def main():
2
+ try:
3
+ fibonacci_numbers = []
4
+ a, b = 0, 1
5
+
6
+ for _ in range(10):
7
+ fibonacci_numbers.append(a)
8
+ a, b = b, a + b
9
+
10
+ result = {
11
+ 'result': fibonacci_numbers
12
+ }
13
+ return result
14
+ except Exception as e:
15
+ return {
16
+ 'result': None,
17
+ 'error': str(e)
18
+ }
@@ -0,0 +1,19 @@
1
+ async def main():
2
+ try:
3
+ import math
4
+
5
+ n = 5
6
+ factorial_result = math.factorial(n)
7
+
8
+ result = {
9
+ 'result': factorial_result,
10
+ 'input': n,
11
+ 'calculation': f'{n}! = {factorial_result}'
12
+ }
13
+
14
+ return result
15
+ except Exception as e:
16
+ return {
17
+ 'result': None,
18
+ 'error': str(e)
19
+ }
@@ -0,0 +1,17 @@
1
+ async def main():
2
+ try:
3
+ calculation_result = 2 + 2
4
+ result = {
5
+ 'result': calculation_result,
6
+ 'expression': '2 + 2',
7
+ 'success': True
8
+ }
9
+ return result
10
+ except Exception as e:
11
+ result = {
12
+ 'result': None,
13
+ 'expression': '2 + 2',
14
+ 'success': False,
15
+ 'error': str(e)
16
+ }
17
+ return result
@@ -0,0 +1,18 @@
1
+ async def main():
2
+ try:
3
+ fibonacci_numbers = []
4
+ a, b = 0, 1
5
+
6
+ for _ in range(10):
7
+ fibonacci_numbers.append(a)
8
+ a, b = b, a + b
9
+
10
+ result = {
11
+ 'result': fibonacci_numbers
12
+ }
13
+ return result
14
+ except Exception as e:
15
+ return {
16
+ 'result': None,
17
+ 'error': str(e)
18
+ }
@@ -0,0 +1,23 @@
1
+ async def main():
2
+ try:
3
+ # Calculate sum of numbers from 1 to 100
4
+ # Using the formula: n * (n + 1) / 2
5
+ n = 100
6
+ sum_formula = n * (n + 1) // 2
7
+
8
+ # Alternative: using sum with range
9
+ sum_range = sum(range(1, 101))
10
+
11
+ result = {
12
+ 'result': sum_formula,
13
+ 'verification': sum_range,
14
+ 'method': 'Gauss formula: n*(n+1)/2',
15
+ 'n': n
16
+ }
17
+
18
+ return result
19
+ except Exception as e:
20
+ return {
21
+ 'result': None,
22
+ 'error': str(e)
23
+ }
@@ -0,0 +1,18 @@
1
+ import math
2
+
3
+ async def main():
4
+ try:
5
+ number = 144
6
+ square_root = math.sqrt(number)
7
+
8
+ result = {
9
+ 'result': square_root,
10
+ 'input': number,
11
+ 'operation': 'square_root'
12
+ }
13
+ return result
14
+ except Exception as e:
15
+ return {
16
+ 'result': None,
17
+ 'error': str(e)
18
+ }
@@ -0,0 +1,17 @@
1
+ async def main():
2
+ try:
3
+ calculation_result = 2 + 2
4
+ result = {
5
+ 'result': calculation_result,
6
+ 'expression': '2 + 2',
7
+ 'success': True
8
+ }
9
+ return result
10
+ except Exception as e:
11
+ result = {
12
+ 'result': None,
13
+ 'expression': '2 + 2',
14
+ 'success': False,
15
+ 'error': str(e)
16
+ }
17
+ return result
@@ -0,0 +1,19 @@
1
+ async def main():
2
+ try:
3
+ import math
4
+
5
+ n = 5
6
+ factorial_result = math.factorial(n)
7
+
8
+ result = {
9
+ 'result': factorial_result,
10
+ 'input': n,
11
+ 'calculation': f'{n}! = {factorial_result}'
12
+ }
13
+
14
+ return result
15
+ except Exception as e:
16
+ return {
17
+ 'result': None,
18
+ 'error': str(e)
19
+ }
@@ -0,0 +1,74 @@
1
+ import math
2
+
3
+ async def main():
4
+ try:
5
+ # Calculate various mathematical results
6
+ calculations = {}
7
+
8
+ # 1. Calculate the golden ratio
9
+ golden_ratio = (1 + math.sqrt(5)) / 2
10
+ calculations['golden_ratio'] = golden_ratio
11
+
12
+ # 2. Calculate e (Euler's number) using series expansion
13
+ e_approximation = sum(1 / math.factorial(n) for n in range(20))
14
+ calculations['e_approximation'] = e_approximation
15
+ calculations['e_actual'] = math.e
16
+
17
+ # 3. Calculate pi using Leibniz formula
18
+ pi_approximation = 4 * sum((-1)**n / (2*n + 1) for n in range(10000))
19
+ calculations['pi_approximation'] = pi_approximation
20
+ calculations['pi_actual'] = math.pi
21
+
22
+ # 4. Calculate factorial of 10
23
+ factorial_10 = math.factorial(10)
24
+ calculations['factorial_10'] = factorial_10
25
+
26
+ # 5. Calculate the sum of first 100 prime numbers
27
+ def is_prime(n):
28
+ if n < 2:
29
+ return False
30
+ for i in range(2, int(math.sqrt(n)) + 1):
31
+ if n % i == 0:
32
+ return False
33
+ return True
34
+
35
+ primes = []
36
+ num = 2
37
+ while len(primes) < 100:
38
+ if is_prime(num):
39
+ primes.append(num)
40
+ num += 1
41
+
42
+ calculations['sum_first_100_primes'] = sum(primes)
43
+ calculations['first_10_primes'] = primes[:10]
44
+
45
+ # 6. Calculate Fibonacci sequence (first 20 numbers)
46
+ def fibonacci(n):
47
+ fib = [0, 1]
48
+ for i in range(2, n):
49
+ fib.append(fib[i-1] + fib[i-2])
50
+ return fib[:n]
51
+
52
+ calculations['fibonacci_20'] = fibonacci(20)
53
+
54
+ # 7. Calculate square root of 2 (irrational number approximation)
55
+ calculations['sqrt_2'] = math.sqrt(2)
56
+
57
+ # 8. Calculate the area of a circle with radius 5
58
+ radius = 5
59
+ calculations['circle_area_r5'] = math.pi * radius ** 2
60
+
61
+ result = {
62
+ 'result': calculations,
63
+ 'status': 'success',
64
+ 'description': 'Various mathematical calculations completed successfully'
65
+ }
66
+
67
+ return result
68
+
69
+ except Exception as e:
70
+ return {
71
+ 'result': None,
72
+ 'status': 'error',
73
+ 'error_message': str(e)
74
+ }