Page 1 sur 1

a small improvement in the canonical_form command

Publié : ven. juin 15, 2018 2:34 pm
par compsystems
Hello BP, a small improvement in the command

if the simplification flag is none return

canonical_form(x^2-6*x) returns (x-3)^2-(-6/2)^2 // “completing the square.”

this allows to show in the classroom, steps as if they were done by hand

current

canonical_form(x^2-6*x) returns (x-3)^2-9

Re: a small improvement in the canonical_form command

Publié : sam. juin 16, 2018 3:10 pm
par parisse
? What the point of not simplifying 6/2?
Anyway, giac reduces rational fractions of integers always.

Re: a small improvement in the canonical_form command

Publié : sam. juin 16, 2018 6:17 pm
par belanger
Leaving the 6/2 unsimplified shows a middle step in the complete the square formula
x^2 + b^x = (x + (b/2))^2 - (b/2)^2
If having simplify set to none would do that, then (I would think) that going through all the steps would require
switching between simplification modes. It might anyhow be easier to write a function
complete_square_step
that (after checking for the variable, making sure you have a second degree polynomial, making it monic, etc.)
returns
(x + quote(coeff(expr,x,1)/2))^2 + (coeff(expr,x,0) - (quote(coeff(expr,x,1)/2)^2)
or something. And then simplify that to finish it.

Re: a small improvement in the canonical_form command

Publié : sam. juin 16, 2018 7:02 pm
par compsystems
I think there should be a new mode: "Didactic CAS"

Source:
free book "Doing Mathematics withScientic WorkPlace"
https://www.sciword.co.uk/manuals/
Image

expr0:=x^2-6*x;
(x + (coeff(expr0,x,1)/2))^2 + (coeff(expr0,x,0) - ((coeff(expr0,x,1)/2)^2)); returns
(x-3)^2-9

(x + quote(coeff(expr0,x,1)/2))^2 + (coeff(expr0,x,0) - (quote(coeff(expr0,x,1)/2)^2)) returns
(x+coeff(expr0,x,1)/2)^2-(coeff(expr0,x,1)/2)^2

canonical_form(x^2-6*x+y^2+10*y=18) returns " Error: Bad Argument Value"

canonical form x^2-6*x+y^2+10*y=-18 http://www.wolframalpha.com/input/?i=ca ... 10*y%3D-18
(x - 3)^2 + (y + 5)^2 - 16 = 0

canonical_form(x^2-6*x+y^2+10*y+18) " returns
(x-3)^2+(4*(y^2+10*y+18)-36)/4

Re: a small improvement in the canonical_form command

Publié : dim. juin 17, 2018 8:55 pm
par parisse
I disagree with the idea that one should keep 6/2 unsimplified in the constant square. As an intermediate step to build the square containing x canceling the linear term, that's acceptable, but not after in my opinion. Anyway, as I explained, Xcas is designed from scratch to simplify rationals, it can not be changed.

Re: a small improvement in the canonical_form command

Publié : jeu. août 23, 2018 4:37 pm
par compsystems
an idea, for expressions of more than one variable, the second argument would specify the "subpolynomy"

canonical_form(x^2-6*x+y^2+10*y+18 , x ) => canonical_form(x^2-6*x, x ) + y^2+10*y+18 => (x-3)^2-9 + y^2+10*y+18

canonical_form(x^2-6*x+y^2+10*y+18 , y ) => canonical_form(y^2+10*y+18 , y )+x^2-6*x => (y+5)^2-7 + x^2-6*x

canonical_form(x^2-6*x+y^2+10*y+18 , [x,y] ) => canonical_form(x^2-6*x, x )+canonical_form(y^2+10*y+18 , y ) => (x-3)^2 + (y+5)^2 -16

Image

Re: a small improvement in the canonical_form command

Publié : ven. août 24, 2018 6:30 am
par parisse
I don't understand your question, canonical_form already accepts a 2nd argument (the variable with respect to which the canonical form is computed).