cancel
Showing results for 
Search instead for 
Did you mean: 
on4now4
Level 1
6 3 1 0
Message 1 of 10
3,362
Flag Post

Solved!

Completing the square

HP Recommended
HP Prime

Is there any way to complete the square on the HP Prime?  The TI-Nspire does this with ease.

 

Ex.(s^2+2s+5) = (s+1)^2+4

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Tim_Wessman
Level 8
Level 8
747 744 121 188
Message 4 of 10
Flag Post
HP Recommended

Surprise!

 

canonical_form( ) is the command you want here. I beleive it is only in the catalog.

 

canonical_form(x^2+2*x+5) -> (x-1)^2+4

TW

Although I work for the HP calculator group as a head developer of the HP Prime, the views and opinions I post here are my own.

View solution in original post

Tags (1)
Was this reply helpful? Yes No
9 REPLIES 9
Fortin
Level 4
127 110 14 18
Message 2 of 10
Flag Post
HP Recommended

I'm not aware of anything built-in, but I've been surprised before...

 

You could try something like the following program.  Please be aware that I tossed this together just now, so it hasn't had extensive testing ... but it seems to function properly.

 

completesquare(x^2+2*x+5)  => (x+1)^2+4

 

 

#cas
completesquare(pf):=
BEGIN

  LOCAL l0;
  l0:=coeff(pf);

  IF SIZE(l0)==3 THEN
      return l0(1)*(x-(-(l0(2)))/(2*l0(1)))^2+l0(3)-(l0(2))^2/(4*l0(1));
  ELSE
     return(pf);
  END;

END;
#end
Tags (1)
Was this reply helpful? Yes No
on4now4
Author
Level 1
6 3 1 0
Message 3 of 10
Flag Post
HP Recommended

Awesome.  Thank you!  I guess its time I learn more about programming these things.  Looks pretty simple coming from the C world

Was this reply helpful? Yes No
Tim_Wessman
Level 8
Level 8
747 744 121 188
Message 4 of 10
Flag Post
HP Recommended

Surprise!

 

canonical_form( ) is the command you want here. I beleive it is only in the catalog.

 

canonical_form(x^2+2*x+5) -> (x-1)^2+4

TW

Although I work for the HP calculator group as a head developer of the HP Prime, the views and opinions I post here are my own.

View solution in original post

Tags (1)
Was this reply helpful? Yes No
Maké
Level 9
3,551 3,299 180 540
Message 5 of 10
Flag Post
HP Recommended

Hi!, Tim:

 

Thank you, by your participation !.

 

Excuse me, for expand, your information ...

 

IMG_20160317_161519.jpg

 

IMG_20160317_163319.jpg

 

IMG_20160317_163028.jpg

 

 IMG_20160317_154036.jpg

Kind Regards !.
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
Was this reply helpful? Yes No
Aleff001
Level 1
9 6 0 0
Message 6 of 10
Flag Post
HP Recommended

Maké, can you tell me what is the "a:= " ?

Was this reply helpful? Yes No
Tim_Wessman
Level 8
Level 8
747 744 121 188
Message 7 of 10
Flag Post
HP Recommended

That is assigning the equation to a variable named "a". It isn't necessary here - doing canonical_form(<equation>) would work just as well. Note how he does canonical_form(a) in the second step. The equation stored in "a" is recalled and used.

 

MyVar:=5

 

makes a variable named "MyVar" with the content of 5 and so on.

 

= by itself is an equality operator. It is setting both sides equal to each other. a=<equation> would be saying "a is equal to <equation>". 

 

:= is the asignment operator. It means "store the value on the left into the variable named "a".

TW

Although I work for the HP calculator group as a head developer of the HP Prime, the views and opinions I post here are my own.
Was this reply helpful? Yes No
Maké
Level 9
3,551 3,299 180 540
Message 8 of 10
Flag Post
HP Recommended

Hi!, @Aleff001:

 

Is defined variable ... a:=

Kind Regards !.
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
Was this reply helpful? Yes No
aamegahed
New member
4 3 0 0
Message 9 of 10
Flag Post
HP Recommended

Is there any way to complete the square on the HP Prime?  The TI-Nspire does this with ease.

 

Ex.(X^2+Y^2+8X+24Y-50X=0)

Was this reply helpful? Yes No
Maké
Level 9
3,551 3,299 180 540
Message 10 of 10
Flag Post
HP Recommended

Hi!, @Aamegahed :

Can you explained better ?.

Kind Regards !.
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
Was this reply helpful? Yes No
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation