Jump to content



Photo
- - - - -

How to make use of output displayed within curly brackets?

roots curly brackets solve

  • Please log in to reply
3 replies to this topic

#1 Btrds17

Btrds17

    Newbie

  • Members
  • Pip
  • 2 posts

  • Calculators:
    fx-CG500, fx-CG50

Posted 11 July 2018 - 03:15 PM

I am writing a program in CasioBASIC for my CG500 to find the roots of the expression below.

f(x) = 0 = -100+60x+16x^2+-2x^3+2x^4

I am using solve() for this, and sending the results, i.e. roots to a variable named "a" 

START OF PROGRAM
ClrText
solve(-100+60x+16x^2+-2x^3+2x^4,x)=>a
Print a

END OF PROGRAM
 

The result is displayed as:
{X=-2.698706525,X=1.240787114}

My main question is about the output, which displays the multiple roots within curly brackets. Does anyone know how to "extract" a specific solution within the curly brackets? There are 2 roots displayed. Let's say, I want to use only the positive root.

 

Is there a way for me to tell the program to do this?

 

What if I wanted to use the negative root, instead? How do I let the program know this?

 

I looked into the fx-CG8500 User Guide again, and found this. It provides some information about braces, but I can't really understand what it is trying to say.  I don't even know whether this information is relevant.  Anyone know what it means? This note was placed under Syntax Conventions, together with a square box (indicates a space), square brackets, the three dots known as a ellipsis, etc. The information on the curly brackets state:

{} You need to select one of the multiple options inside the braces ({}).
Example: {On ; Off ; Number}
When inputting the command, do not include the braces or semicolons.



#2 pan.gejt

pan.gejt

    Casio Freak

  • Members
  • PipPipPipPip
  • 264 posts
  • Gender:Male
  • Location:CZ

  • Calculators:
    .

Posted 11 July 2018 - 05:10 PM

You can restrict your solution for certain domain (eg. x<0, x>0, x betwen b and c) . The syntax of solve command should be follows:

solve(eq,x,a,b,c)=>d

 

eq - equation

x - variable

a - initial value

b - lower limit

c - upper limit

d - result

 

Although the "x=something" is displayed, you can use the result in further calcuations


  • Btrds17 likes this

#3 Btrds17

Btrds17

    Newbie

  • Members
  • Pip
  • 2 posts

  • Calculators:
    fx-CG500, fx-CG50

Posted 11 July 2018 - 10:12 PM

Thank you so much, pan.getj. If I may ask, where did you get the syntax of solve, i.e. solve(eq,x,a,b,c) from?  I never saw that in the Casio User Manual.  Is there a more detailed Casio programming manual?  From a general BASIC programming guide, maybe?

 

Anyway, I tried your suggestion.  I set the initial value as 1, placed a lower limit of -0.001 and an upper limit of 50, so as to only get the positive root. I also did a multiplication and division exercise with the result.

 

Start of Program:

 

ClrText
solve(-100+60x+16x^2+-2x^3+2x^4,x,1,-.001,50)=>d
Print d

2.5d=>e

6/d=>f

Print e

Print f

 

End of Program.

 

The program ran fine, and here is the Output.

 

{x=1.240787114}

{2.5.x=3.101967784}

{6/x=4.835640162}

 

The result is still always enclosed in the curly brackets, or braces, though. Is there a way to make the result a "regular" number, i.e. without the curly brackets, or braces?  That way, I will be able to further manipulate the result, e.g. use it in a list with a few other "regular" numbers to find min, or max, etc.

 

When I tried to:  Print x

The output is just: x

No numerical value provided for x.

 

Is there to get just: x=1.24787114 

Without the curly brackets, or braces.

 

Thanks again, and I hope other users will be able to provide input, advice, suggestions, etc.



#4 pan.gejt

pan.gejt

    Casio Freak

  • Members
  • PipPipPipPip
  • 264 posts
  • Gender:Male
  • Location:CZ

  • Calculators:
    .

Posted 12 July 2018 - 01:38 PM

Well, intially I got the syntax from the calculator menu: In "Main" tap interactive - advanced - solve or tap interactive - equation/inequality - solve. Check the "solve numerically".

The syntax I also found in quick reference guide (page 10) and user guide (page 81, syntax 2)

https://www.casioedu...aphing/fx-cg500

 

Unfortunately I didn't find any way how to obtain number only till now. I tried them methods as you wrote above, string commands and no luck

Maybe the better way is to create own program for solving by using e.g. Newton method. You can define your function in programm, see the "define"  "input  function" command in the UG. You can add to your program the DrawGraph command to estimate the roots before you start the solving.

 

.....

InputFunc f1(x)

DrawGraph f1(x) 

Pause

.............. 


Edited by pan.gejt, 13 July 2018 - 11:49 AM.




Also tagged with one or more of these keywords: roots, curly brackets, solve

2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users