Message Boards Message Boards

Create a Step-by-step equation solver API?

Posted 7 years ago

Ok, the idea seems very weird...I know. I'm a very big noob at Mathematica, I downloaded it 2 weeks ago, but I think that's the most awesome software on earth. Anyway, I know that it's possible to get Step-by-step solution using Wolfram Alpha like this: WolframAlpha["x^2=x+1"] And I also know that it's possible to deploy an API using the Cloud Deploy function, but I would like to create an API that when you input: ?q=x^2==x+1 returns a JSON array like this:

{
  "1": {
    "text": "Solve for x over the real numbers:",
    "expression": "x^2==x+1"
  },
  "2": {
    "text": "Subtract x+1 from both sides:",
    "expression": "x^2-x-1==0"
  },
  "3": {
    "text": "Add 1 to both sides:",
    "expression": "x^2-x==1"
  },
  "4": {
    "text": "Add 1/4 to both sides:",
    "expression": "x^2-x+1/4==5/4"
  },
  "5": {
    "text": "Write the left hand side as a square:",
    "expression": "(x-1/2)^2==5/4"
  },
  "6": {
    "text": "Take the square root of both sides:",
    "expression": "x-1/2==Sqrt[5]/2 or x-1/2==-(Sqrt[5]/2)"
  },
  "7": {
    "text": "Add 1/2 to both sides:",
    "expression": "x==1/2+Sqrt[5]/2 or x-1/2==-(Sqrt[5]/2)"
  },
  "8": {
    "text": "Add 1/2 to both sides:",
    "expression": "x==1/2+Sqrt[5]/2 or x==1/2-Sqrt[5]/2"
  }
}

Or something like this. I know that's it's ambitious, and I don't expect something with tons of options, as I said, I want something simple (if it's possible to do of course :) ). Thank you for taking your time reading my question, and I hope it's possible to do. You can see this as a challenge ;)

POSTED BY: Arthur Guiot
4 Replies

Why not using Wolfram|Alpha API directly? https://products.wolframalpha.com/api

POSTED BY: Kapio Letto
Posted 7 years ago

Then, how should I proceed?

POSTED BY: Arthur Guiot

Arthur,

This will give you the step-by-step from Alpha as a graphic:

jnk = WolframAlpha["x^2==x+1",IncludePods->{"Solution"},PodStates->{"Solution__Step-by-step solution"}]

or you can get the XML and parse it:

jnk = WolframAlpha["x^2==x+1","XML",IncludePods->{"Solution"},PodStates->{"Solution__Step-by-step solution"}]

I figured this out by doing this:

WolframAlpha["x^2==x+1","PodStates"]

Which gave me:

{Solution->{Solution..Approximate forms,Solution..Step-by-step solution}}

(note the two dots (..) are actually two underscores that don't appear properly on the forum)

So I had to Include the Solution pod and ask for the step-by-step PodState

I hope this helps

POSTED BY: Neil Singer

or you can get the Plaintext version:

jnk = WolframAlpha["x^2==x+1","PodPlaintext",IncludePods->{"Solution"},PodStates->{"Solution__Step-by-step solution"}]

and construct your own JSON from that

POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract