AR14020 commited on
Commit
34f4225
Β·
verified Β·
1 Parent(s): 75c3b54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -15
app.py CHANGED
@@ -6,28 +6,29 @@ def main():
6
  st.title("Integration by Parts - Step-by-Step Solver")
7
  st.markdown(
8
  """
9
- Integration by Parts formula:
10
- \
11
  \\int u \\cdot v' \\, dx = u \\cdot v - \\int v \\cdot u' \\, dx
12
- \
13
  """
14
  )
15
 
16
  # Input section
17
- st.header("Input Function")
18
  function_input = st.text_input(
19
- "Enter the integrand (e.g., x * exp(x) or ln(x)):", "x * exp(x)"
 
20
  )
21
  u_input = st.text_input(
22
- "Choose 'u' (e.g., x for x * exp(x)):",
23
- "x"
24
  )
25
 
26
- # Process inputs
27
  if st.button("Solve"):
28
  try:
 
29
  x = symbols("x")
30
- # Parse the integrand and chosen `u`
 
31
  integrand = eval(function_input)
32
  u = eval(u_input)
33
  dv = integrand / u
@@ -36,18 +37,35 @@ def main():
36
  du = diff(u, x)
37
  v = integrate(dv, x)
38
 
39
- # Apply the formula
40
- result = u * v - integrate(v * du, x)
 
 
41
 
42
  # Display steps
43
  st.subheader("Step-by-Step Solution")
 
 
44
  st.latex(f"u = {latex(u)}, \\quad v' = {latex(dv)}")
45
- st.latex(f"du = {latex(du)}, \\quad v = \\int {latex(dv)} \\, dx = {latex(v)}")
46
- st.markdown("Substituting into the formula:")
 
 
 
 
47
  st.latex(
48
- f"\\int {latex(integrand)} \\, dx = {latex(u)} \\cdot {latex(v)} - \\int {latex(v)} \\cdot {latex(du)} \\, dx"
49
  )
50
- st.latex(f"= {latex(result)} + C")
 
 
 
 
 
 
 
 
 
51
 
52
  # Final output
53
  st.subheader("Final Answer")
 
6
  st.title("Integration by Parts - Step-by-Step Solver")
7
  st.markdown(
8
  """
9
+ ## Formula for Integration by Parts
10
+ \[
11
  \\int u \\cdot v' \\, dx = u \\cdot v - \\int v \\cdot u' \\, dx
12
+ \]
13
  """
14
  )
15
 
16
  # Input section
17
+ st.header("Input the Function")
18
  function_input = st.text_input(
19
+ "Enter the integrand (e.g., x * exp(x), ln(x), x^2 * cos(x)):",
20
+ "x * exp(x)",
21
  )
22
  u_input = st.text_input(
23
+ "Choose 'u' (e.g., x for x * exp(x) or ln(x)):", "x"
 
24
  )
25
 
 
26
  if st.button("Solve"):
27
  try:
28
+ # Define the variable
29
  x = symbols("x")
30
+
31
+ # Parse inputs
32
  integrand = eval(function_input)
33
  u = eval(u_input)
34
  dv = integrand / u
 
37
  du = diff(u, x)
38
  v = integrate(dv, x)
39
 
40
+ # Compute the result
41
+ first_term = u * v
42
+ second_term = integrate(v * du, x)
43
+ result = first_term - second_term
44
 
45
  # Display steps
46
  st.subheader("Step-by-Step Solution")
47
+
48
+ st.markdown("### 1. Choose u and v':")
49
  st.latex(f"u = {latex(u)}, \\quad v' = {latex(dv)}")
50
+
51
+ st.markdown("### 2. Compute du and v:")
52
+ st.latex(f"du = \\frac{{d}}{{dx}}[{latex(u)}] = {latex(du)}")
53
+ st.latex(f"v = \\int {latex(dv)} \\, dx = {latex(v)}")
54
+
55
+ st.markdown("### 3. Apply the Integration by Parts Formula:")
56
  st.latex(
57
+ f"\\int {latex(integrand)} \\, dx = u \\cdot v - \\int v \\cdot du"
58
  )
59
+ st.latex(
60
+ f"= ({latex(u)})({latex(v)}) - \\int ({latex(v)})({latex(du)}) \\, dx"
61
+ )
62
+
63
+ st.markdown("### 4. Evaluate the Terms:")
64
+ st.latex(f"First Term = {latex(first_term)}")
65
+ st.latex(f"Second Term = \\int {latex(v * du)} \\, dx = {latex(second_term)}")
66
+
67
+ st.markdown("### 5. Combine Results:")
68
+ st.latex(f"\\int {latex(integrand)} \\, dx = {latex(result)} + C")
69
 
70
  # Final output
71
  st.subheader("Final Answer")