Maple code to perform mathematical operations on the output of isolve

42 Views Asked by At

The maple command isolve$(x^2-y^2=4)$ returns the output {$x=-2,y=0$}, {$x=2,y=0$} . Its not possible to perform mathematical operations directly on the values of $x$ and $y$. I need help with code that extracts the values of $x$ and $y$ for each solution then perform arithmetic on them. For example for each solution check if $x>y$ , and if true add the values of $x$ and $y$. This is useful when we need to perform arithmetic operations on the output of isolve in a loop. For instance we might need to solve the equation $x^2-y^2=a$ in positive integers $x,y$ where $a$ runs through the positive integers less than say 1000 and print only solutions for which $x+y>30$.

1

There are 1 best solutions below

1
On BEST ANSWER

Something like this?

for a from 1 to 1000 do
  R:= [isolve(x^2-y^2=a)];
  for r in R do
    xr:= subs(r, x);
    yr:= subs(r, y);
    if xr + yr > 30 then printf("a=%d x=%d y=%d\n",a,xr,yr) fi
od od: