-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminerva_python_prompt.py
82 lines (64 loc) · 2.32 KB
/
minerva_python_prompt.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
71
72
73
74
75
76
77
78
79
80
81
82
"""
This file contains a Python prompt and a template to compose solutions
to math problems.
The PYTHON_PROMPT string includes an introduction comment that explains
the tasks, followed by a function stub for user's solution.
"""
MINERVA_PYTHON_PROMPT = '''# Language: Python 3
# Task: Synthesize function to solve the problem
"""
Contains maths exercises formulated in doc-strings of functions.
Solutions are written in simple python code and with a lot of comments
that explain what is done and why and how it is related to the specification.
"""
def exercise1():
"""
Find the domain of the expression \(\frac{\sqrt{x-2}}{\sqrt{5-x}}\).
"""
import sympy as sp
# Define the variable
x = sp.symbols('x')
# Define the intervals for the numerator and denominator
numerator_interval = sp.solve_univariate_inequality(x-2 >= 0, x, relational=False)
denominator_interval = sp.solve_univariate_inequality(5-x > 0, x, relational=False)
# Find the intersection of the intervals to get the domain
overall_domain = sp.Intersection(numerator_interval, denominator_interval)
return overall_domain
def exercise2():
"""
Given that \(\det \mathbf{A} = 2\) and \(\det \mathbf{B} = 12\),
find \(\det (\mathbf{A} \mathbf{B})\).
"""
det_A = 2
det_B = 12
# Calculate the determinant of the product
det_product_solution = det_A * det_B
return det_product_solution
def exercise3():
"""
Terrell usually lifts two 20-pound weights 12 times.
If he switches to two 15-pound weights, how many times must he lift
them to match the total weight lifted earlier?
"""
weight_20 = 20
times_20 = 12
# Calculate the total weight Terrell lifts with 20-pound weights
total_weight_20_solution = 2 * weight_20 * times_20
# Calculate the number of times Terrell should lift the 15-pound weights
weight_15 = 15
times_15_solution = total_weight_20_solution / (2 * weight_15)
return times_15_solution
def exercise4():
"""
Given the system of equations:
6x-4y = a
6y-9x = b
Determine the value of \( \frac{a}{b} \).
"""
import sympy as sp
a, b, y = sp.symbols('a b y')
x_expr = (a + 4*y) / 6
b_expr = 6*y - 9*x_expr
a_over_b_solution = a / b_expr
return a_over_b_solution.simplify()
'''