Search code examples
sagewolframalpha

How to assign equation-expression to variable then sent to solve()?


I am using both SageMath and Wolfram Alpha to entertain myself over the weekend.

I found this SageMath demo of solving simultaneous equations:

var('x y p q')
eq1 = p+q==9
eq2 = q*y+p*x==-6
eq3 = q*y^2+p*x^2==24
solve([eq1,eq2,eq3,p==1],p,q,x,y)

And it gave me this result:

[
  [ p == 1
  , q == 8
  , x == -4/3*sqrt(10) - 2/3
  , y == 1/6*sqrt(10) - 2/3
  ]
  ,[p == 1
  , q == 8
  , x == 4/3*sqrt(10) - 2/3
  , y == -1/6*sqrt(10) - 2/3
  ]
]

I tried this syntax on Alpha:

solve p+q==9 , q*y+p*x==-6 , q*y^2+p*x^2==24 , p==1

It works well.

Question:

How to operate Alpha so I assign each equation to a variable and then supply that variable to solve as a parameter?

I want to simplify my call to solve() so it looks like this:

solve eq1, eq2, eq3, p==1

instead of this:

solve p+q==9 , q*y+p*x==-6 , q*y^2+p*x^2==24 , p==1

Solution

  • So, Crazy Ivan's comment really answers this. WolframAlpha is not a programming language. It is a glorified online smart calculator. You can only do very limited computations in it. Check out the Wolfram Language for the full-fledged programming language.