Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Step by step solutions #92

Open
DenverCoder1 opened this issue Jun 29, 2021 · 2 comments
Open

Feature: Step by step solutions #92

DenverCoder1 opened this issue Jun 29, 2021 · 2 comments

Comments

@DenverCoder1
Copy link
Contributor

Wolfram Alpha provides step by step solutions for some problems through their API.

This would be an extremely useful feature for this bot and it shouldn't be difficult to implement assuming you already use the WA API.

More details: https://products.wolframalpha.com/show-steps-api/documentation/

Example query: Note: it is required to pass an APIKEY (which I have removed for privacy)

https://api.wolframalpha.com/v2/query?appid=APIKEY&input=integral%20x^3%20ln^2%20x%20dx&podstate=Step-by-step%20solution&format=image

Query result
<?xml version='1.0' encoding='UTF-8'?>
<queryresult success='true'
    error='false'
    xml:space='preserve'
    numpods='5'
    datatypes=''
    timedout=''
    timedoutpods=''
    timing='4.075'
    parsetiming='0.507'
    parsetimedout='false'
    recalculate=''
    id='MSP6227185ba9226487e03500005534f25c7f5690h1'
    host='https://www5a.wolframalpha.com'
    server='42'
    related='https://www5a.wolframalpha.com/api/v1/relatedQueries.jsp?id=MSPa6228185ba9226487e03500001ecg2hc0g7afb47f3773634836471742935'
    version='2.6'
    inputstring='integral x^3 ln^2 x dx'>
 <pod title='Indefinite integrals'
     scanner='Integral'
     id='IndefiniteIntegral'
     position='100'
     error='false'
     numsubpods='2'
     primary='true'>
  <subpod title=''>
   <img src='https://www5a.wolframalpha.com/Calculate/MSP/MSP6229185ba9226487e03500004f6ia342d3595215?MSPStoreType=image/gif&amp;s=42'
       alt='integral x^3 log^2(x) dx = 1/32 x^4 (8 log^2(x) - 4 log(x) + 1) + constant'
       title='integral x^3 log^2(x) dx = 1/32 x^4 (8 log^2(x) - 4 log(x) + 1) + constant'
       width='403'
       height='38'
       type='Default'
       themes='1,2,3,4,5,6,7,8,9,10,11,12'
       colorinvertable='true' />
  </subpod>
  <subpod title='Possible intermediate steps'>
   <img src='https://www5a.wolframalpha.com/Calculate/MSP/MSP6230185ba9226487e03500002b8b54i9604c3i4a?MSPStoreType=image/gif&amp;s=42'
       alt='Take the integral:
 integral x^3 log^2(x) dx
For the integrand x^3 log^2(x), integrate by parts, integral f dg = f g - integral g df, where 
 f = log^2(x), dg = x^3 dx, df = (2 log(x))/x dx, g = x^4/4:
 = 1/4 x^4 log^2(x) - 1/4 integral2 x^3 log(x) dx
Factor out constants:
 = 1/4 x^4 log^2(x) - 1/2 integral x^3 log(x) dx
For the integrand x^3 log(x), integrate by parts, integral f dg = f g - integral g df, where 
 f = log(x), dg = x^3 dx, df = 1/x dx, g = x^4/4:
 = -1/8 x^4 log(x) + 1/4 x^4 log^2(x) + 1/8 integral x^3 dx
The integral of x^3 is x^4/4:
 = x^4/32 + 1/4 x^4 log^2(x) - 1/8 x^4 log(x) + constant
Which is equal to:
Answer: | 
 | = 1/32 x^4 (8 log^2(x) - 4 log(x) + 1) + constant'
       title='Take the integral:
 integral x^3 log^2(x) dx
For the integrand x^3 log^2(x), integrate by parts, integral f dg = f g - integral g df, where 
 f = log^2(x), dg = x^3 dx, df = (2 log(x))/x dx, g = x^4/4:
 = 1/4 x^4 log^2(x) - 1/4 integral2 x^3 log(x) dx
Factor out constants:
 = 1/4 x^4 log^2(x) - 1/2 integral x^3 log(x) dx
For the integrand x^3 log(x), integrate by parts, integral f dg = f g - integral g df, where 
 f = log(x), dg = x^3 dx, df = 1/x dx, g = x^4/4:
 = -1/8 x^4 log(x) + 1/4 x^4 log^2(x) + 1/8 integral x^3 dx
The integral of x^3 is x^4/4:
 = x^4/32 + 1/4 x^4 log^2(x) - 1/8 x^4 log(x) + constant
Which is equal to:
Answer: | 
 | = 1/32 x^4 (8 log^2(x) - 4 log(x) + 1) + constant'
       width='524'
       height='806'
       type='Default'
       themes='1,2,3,4,5,6,7,8,9,10,11,12'
       colorinvertable='true' />
   <infos count='1'>
    <info text='log(x) is the natural logarithm'>
     <img src='https://www5a.wolframalpha.com/Calculate/MSP/MSP6231185ba9226487e0350000681d47e441725b11?MSPStoreType=image/gif&amp;s=42'
         alt='log(x) is the natural logarithm'
         title='log(x) is the natural logarithm'
         width='198'
         height='19' />
     <link url='http://reference.wolfram.com/language/ref/Log.html'
         text='Documentation'
         title='Mathematica' />
     <link url='http://functions.wolfram.com/ElementaryFunctions/Log'
         text='Properties'
         title='Wolfram Functions Site' />
     <link url='http://mathworld.wolfram.com/NaturalLogarithm.html'
         text='Definition'
         title='MathWorld' />
    </info>
   </infos>
  </subpod>
  <expressiontypes count='2'>
   <expressiontype name='Default' />
   <expressiontype name='Default' />
  </expressiontypes>
  <states count='1'>
   <state name='Hide steps'
       input='IndefiniteIntegral__Hide steps' />
  </states>
 </pod>
 <pod title='Plots of the integral'
     scanner='Integral'
     id='Plot'
     position='200'
     error='false'
     numsubpods='2'>
  <subpod title=''>
   <img src='https://www5a.wolframalpha.com/Calculate/MSP/MSP6232185ba9226487e03500002g128g6cea8c7894?MSPStoreType=image/gif&amp;s=42'
       alt='Plots of the integral'
       title=''
       width='335'
       height='134'
       type='2DMathPlot_1'
       themes='1,2,3,4,5,6,7,8,9,10,11,12'
       colorinvertable='true' />
  </subpod>
  <subpod title=''>
   <img src='https://www5a.wolframalpha.com/Calculate/MSP/MSP6233185ba9226487e035000027cc6ig523diai4d?MSPStoreType=image/gif&amp;s=42'
       alt='Plots of the integral'
       title=''
       width='335'
       height='135'
       type='2DMathPlot_1'
       themes='1,2,3,4,5,6,7,8,9,10,11,12'
       colorinvertable='true' />
  </subpod>
  <expressiontypes count='2'>
   <expressiontype name='2DMathPlot' />
   <expressiontype name='2DMathPlot' />
  </expressiontypes>
  <states count='1'>
   <statelist count='2'
       value='Complex-valued plots'
       delimiters=''>
    <state name='Complex-valued plots'
        input='Plot__Complex-valued plots' />
    <state name='Real-valued plots'
        input='Plot__Real-valued plots' />
   </statelist>
  </states>
 </pod>
 <pod title='Alternate form of the integral'
     scanner='Integral'
     id='AlternateFormOfTheIntegral'
     position='300'
     error='false'
     numsubpods='1'>
  <subpod title=''>
   <img src='https://www5a.wolframalpha.com/Calculate/MSP/MSP6234185ba9226487e03500001050902e1ii63fea?MSPStoreType=image/gif&amp;s=42'
       alt='x^4 ((log^2(x))/4 - log(x)/8 + 1/32) + constant'
       title='x^4 ((log^2(x))/4 - log(x)/8 + 1/32) + constant'
       width='255'
       height='49'
       type='Default'
       themes='1,2,3,4,5,6,7,8,9,10,11,12'
       colorinvertable='true' />
  </subpod>
  <expressiontypes count='1'>
   <expressiontype name='Default' />
  </expressiontypes>
 </pod>
 <pod title='Expanded form of the integrals'
     scanner='Integral'
     id='ExpandedFormOfTheIntegral'
     position='400'
     error='false'
     numsubpods='2'>
  <subpod title=''>
   <img src='https://www5a.wolframalpha.com/Calculate/MSP/MSP6235185ba9226487e035000052h887g2a766d42f?MSPStoreType=image/gif&amp;s=42'
       alt='x^4/32 + 1/4 x^4 log^2(x) - 1/8 x^4 log(x) + constant'
       title='x^4/32 + 1/4 x^4 log^2(x) - 1/8 x^4 log(x) + constant'
       width='285'
       height='43'
       type='Default'
       themes='1,2,3,4,5,6,7,8,9,10,11,12'
       colorinvertable='true' />
  </subpod>
  <subpod title='Possible intermediate steps'>
   <img src='https://www5a.wolframalpha.com/Calculate/MSP/MSP6236185ba9226487e03500005d4ffa71b9ga81aa?MSPStoreType=image/gif&amp;s=42'
       alt='Expand the following:
(x^4 (1 - 4 log(x) + 8 log(x)^2))/32
x^4 (1 - 4 log(x) + 8 log(x)^2) = x^4×1 + x^4 (-4 log(x)) + x^4×8 log(x)^2:
(x^4 - 4 x^4 log(x) + 8 x^4 log(x)^2)/32
(x^4 - 4 x^4 log(x) + 8 x^4 log(x)^2)/32 = x^4/32 - (4 x^4 log(x))/32 + (8 x^4 log(x)^2)/32:
x^4/32 - (4 x^4 log(x))/32 + (8 x^4 log(x)^2)/32
The gcd of -4 and 32 is 4, so (-4 x^4 log(x))/32 = ((4 (-1)) x^4 log(x))/(4×8) = 4/4×(-x^4 log(x))/8 = (-x^4 log(x))/8:
x^4/32 + (-1 x^4 log(x))/8 + (8 x^4 log(x)^2)/32
8/32 = 8/(8×4) = 1/4:
Answer: | 
 | x^4/32 - (x^4 log(x))/8 + (x^4 log(x)^2)/4'
       title='Expand the following:
(x^4 (1 - 4 log(x) + 8 log(x)^2))/32
x^4 (1 - 4 log(x) + 8 log(x)^2) = x^4×1 + x^4 (-4 log(x)) + x^4×8 log(x)^2:
(x^4 - 4 x^4 log(x) + 8 x^4 log(x)^2)/32
(x^4 - 4 x^4 log(x) + 8 x^4 log(x)^2)/32 = x^4/32 - (4 x^4 log(x))/32 + (8 x^4 log(x)^2)/32:
x^4/32 - (4 x^4 log(x))/32 + (8 x^4 log(x)^2)/32
The gcd of -4 and 32 is 4, so (-4 x^4 log(x))/32 = ((4 (-1)) x^4 log(x))/(4×8) = 4/4×(-x^4 log(x))/8 = (-x^4 log(x))/8:
x^4/32 + (-1 x^4 log(x))/8 + (8 x^4 log(x)^2)/32
8/32 = 8/(8×4) = 1/4:
Answer: | 
 | x^4/32 - (x^4 log(x))/8 + (x^4 log(x)^2)/4'
       width='450'
       height='666'
       type='Default'
       themes='1,2,3,4,5,6,7,8,9,10,11,12'
       colorinvertable='true' />
  </subpod>
  <expressiontypes count='2'>
   <expressiontype name='Default' />
   <expressiontype name='Default' />
  </expressiontypes>
  <states count='1'>
   <state name='Hide steps'
       input='ExpandedFormOfTheIntegral__Hide steps' />
  </states>
 </pod>
 <pod title='Definite integral'
     scanner='Integral'
     id='DefiniteIntegral'
     position='500'
     error='false'
     numsubpods='1'>
  <subpod title=''>
   <img src='https://www5a.wolframalpha.com/Calculate/MSP/MSP6237185ba9226487e03500005g0baeieh53cd3c0?MSPStoreType=image/gif&amp;s=42'
       alt='integral_0^1 x^3 log^2(x) dx = 1/32 = 0.03125'
       title='integral_0^1 x^3 log^2(x) dx = 1/32 = 0.03125'
       width='224'
       height='38'
       type='Default'
       themes='1,2,3,4,5,6,7,8,9,10,11,12'
       colorinvertable='true' />
  </subpod>
  <expressiontypes count='1'>
   <expressiontype name='Default' />
  </expressiontypes>
 </pod>
</queryresult>

The second link (https://www4b.wolframalpha.com/Calculate/MSP/MSP20411ebib521338c9a5800005h54e68eb6i7i8f4?MSPStoreType=image/gif&s=38) displays this image:

Example step by step image

image

If this could be implemented, that would be awesome.

Thanks!

@sonataop13
Copy link
Contributor

Isn't the step-by-step API like $10K per year?

@DenverCoder1
Copy link
Contributor Author

@sonataop13 Only after a certain amount of queries (which I assume a bot of this size probably would use up).

Maybe it can be made available for developers to enable if they are hosting it themselves?

That way if you only need a few queries per month, you can do it with your own API key?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants