Les membres ayant 30 points peuvent parler sur les canaux annonces, projets et hs du chat.
La shoutbox n'est pas chargée par défaut pour des raisons de performances. Cliquez pour charger.

Forum Casio - Discussions


Index du Forum » Discussions » Casio Basic Beginner Questions
Timothy529 Hors ligne Membre Points: 32 Défis: 0 Message

Casio Basic Beginner Questions

Posté le 19/10/2021 16:40

Hello everyone, apologies for the english, I can google translate my posts to french before posting in the future if that is preferred. I am working on some projects for my classes to make tests easier and expand my knowledge of these calculators, and while there are a few good resources for the Casio BASIC programming language, I still have quite a few questions that are left unanswered. I am making this post to see if anyone would be kind enough to help me understand how I should go about accomplishing a few things I am unsure of how to do. Any replies would be appreciated. Thanks!

My first question is: when using
SolveN( Det (Mat A-(XIdentity M))=0)
in an If statement, how do I pause on the ListAns that is displayed after running this, or even store it in a list for later use? And how would I display that list?


1, 2 Suivante
Lephenixnoir Hors ligne Administrateur Points: 24145 Défis: 170 Message

Citer : Posté le 19/10/2021 16:43 | #


Hi! English is fine I guess. Less people will understand it, but you'll get answers anyway

List Ans is the list where a list result is stored if you don't store it yourself, like Ans. You can pause on it with ◢ :

SolveN( Det (Mat A-(XIdentity M))=0)◢

Or you can later show the list:

SolveN( Det (Mat A-(XIdentity M))=0)
List Ans◢

Or you can save it to a list of your choice:

SolveN( Det (Mat A-(XIdentity M))=0)→List 1

And then do whatever you want to with List 1.
Mon graphe (24 Mars): (gint#27 ; (Rogue Life || HH2) ; PythonExtra ; serial gint ; Boson X ; ...) || (shoutbox v5 ; v5)
Thebigbadboy Hors ligne Maître du Puzzle Points: 455 Défis: 16 Message

Citer : Posté le 19/10/2021 17:13 | #


Hi

I just have to warn you about 2 things :

- If statement can only test a scalar condition (not a list, even of one element). Then you need something like If Dim List 1. (Perhaps a thing you already did)

- If there is any chance of not getting any zeros (I think there is, because I guess you would like to compute the real eigenvalues), using the (empty) list returned by SolveN() will display an error. To avoid this, it is better to "play" with List Ans :
{i} //set the List Ans with one element having a complex part. We know the SolveN won't return complex elements
SolveN(Det (Mat A-XIdentity M)) //if it found solution-s, List Ans will be overwritten (if not, then List Ans is still having a complex number)
If List Ans[1]≠i //if we found at least a REAL eigenvalue


Also, the =0 in your SolveN is not necessary : SolveN finds all the roots of a function by default
Un problème sans solution est un problème mal posé — Albert Einstein
Lephenixnoir Hors ligne Administrateur Points: 24145 Défis: 170 Message

Citer : Posté le 19/10/2021 17:15 | #


Aah, that's a good point, empty lists are basically illegal in Casio BASIC. You have to work around them...
Mon graphe (24 Mars): (gint#27 ; (Rogue Life || HH2) ; PythonExtra ; serial gint ; Boson X ; ...) || (shoutbox v5 ; v5)
Timothy529 Hors ligne Membre Points: 32 Défis: 0 Message

Citer : Posté le 19/10/2021 17:22 | #


Je peux traduire si c'est plus pratique pour tout le monde. J'espère juste que Google traduit tout correctement, haha. Merci, c'est bien mieux que ce que j'ai trouvé. J'essaie actuellement de comprendre comment identifier les entrées principales dans une matrice pour déterminer les variables libres afin de les convertir en forme vectorielle paramétrique. Je mettrai à jour avec toutes les questions.

Ajouté le 19/10/2021 à 17:30 :
Thebigbadboy a écrit :

{i} //set the List Ans with one element having a complex part. We know the SolveN won't return complex elements



Je vois, je n'étais pas au courant de ce problème. Comment cela mettra-t-il ListAns à zéro ? BIDE me donne des erreurs de compilation.

Ajouté le 19/10/2021 à 17:30 :
Thebigbadboy a écrit :

If List Ans [1] ≠ i // if we found at least a REAL eigenvalue



Cette instruction If incomplète sert à quelle fonction ? Je m'excuse, je suis un peu confus ici.
Timothy529 Hors ligne Membre Points: 32 Défis: 0 Message

Citer : Posté le 19/10/2021 18:04 | # | Fichier joint


Peut-être vaudrait-il mieux expliquer ce que je fais ici. Comme vous l'avez déjà compris, je trouve des valeurs propres. Je prépare un programme pour mon prochain test d'algèbre linéaire afin de réduire la quantité de travail que je devrai faire à la main.
#Program name: EigenVal
#Password: <no password>
"Eigenvalue Solver"
"by Timothy529"
Lbl 1
"0: Input Matrix A"
"1: EigenValue Solver"
"2: Find EigenSpace"
"3:"
"4:"
? -> Z
If Z = 0 :Then
    ClrText
    "input Matrix Dimensions:"
    "M: "? -> M
    {M, M} -> Dim Mat A
    For 1 -> I To M
        For 1 -> J To M
            ClrText
            "Input value for"
            Locate 17, 1, I
            Locate 19, 1, J
            ? -> A
            A -> Mat A[I, J]
        Next
    Next
    ClrText
    Goto 1
IfEnd
If Z = 1 :Then
SolveN(Det (Mat A-XIdentity M)◢
Goto 1
IfEnd

J'utilise BIDE pour ce faire, et pour le moment mon objectif est les valeurs propres et l'espace propre d'une valeur, mais je suis sûr que j'en ajouterai d'autres après les avoir terminés.
Lephenixnoir Hors ligne Administrateur Points: 24145 Défis: 170 Message

Citer : Posté le 19/10/2021 18:57 | #


D'accord pour la traduction, dis-nous si tu ne comprends pas les réponses

Cette instruction If incomplète sert à quelle fonction ? Je m'excuse, je suis un peu confus ici.

Voilà ce que j'ai compris : comme une liste ne peut pas être vide, s'il n'y a pas de solution SolveN() laisse la liste inchangée. Le test "If List Ans[1]≠i" détermine si la liste a été changée. En effet, comme SolveN() ne produit que des racines réelles, si la liste a été changée alors le premier élément ne peut pas être égal à i.

Concernant BIDE, soit il faut utiliser une notation spéciale pour le i complexe soit il ne supporte pas les complexes dans les listes (mais ce serait étonnant).

Peut-être que le programme de Diagonalisation de matrices d'Alex_1186 te sera utile comme référence
Mon graphe (24 Mars): (gint#27 ; (Rogue Life || HH2) ; PythonExtra ; serial gint ; Boson X ; ...) || (shoutbox v5 ; v5)
Timothy529 Hors ligne Membre Points: 32 Défis: 0 Message

Citer : Posté le 19/10/2021 19:31 | # | Fichier joint


Je pense que je le comprends maintenant. Cela a-t-il l'air correct ?
{i}
SolveN(Det (Mat A-XIdentity M)
If List Ans[1] ≠ i
Then
List Ans -> List1
List1◢
Else
"No Real EigenValues"◢
IfEnd
Lephenixnoir Hors ligne Administrateur Points: 24145 Défis: 170 Message

Citer : Posté le 19/10/2021 19:38 | #


Je crois que c'est ça oui
Mon graphe (24 Mars): (gint#27 ; (Rogue Life || HH2) ; PythonExtra ; serial gint ; Boson X ; ...) || (shoutbox v5 ; v5)
Zezombye Hors ligne Rédacteur Points: 1756 Défis: 13 Message

Citer : Posté le 20/10/2021 05:18 | #


You need to use the bold i (&i;) rather than the normal lowercase i.
Divers jeux : Puissance 4 - Chariot Wars - Sokoban
Ecrivez vos programmes basic sur PC avec BIDE
Timothy529 Hors ligne Membre Points: 32 Défis: 0 Message

Citer : Posté le 28/10/2021 15:56 | # | Fichier joint


Salut tout le monde, je suis de retour. J'ai terminé le test d'algèbre linéaire pour lequel j'utilisais cela, et maintenant je cherche à y ajouter le prochain ensemble de fonctions. Pour commencer, j'ai ajouté mon fichier actuel à ce post au cas où quelqu'un voudrait voir où j'en suis. Thebigbadboy a mentionné qu'il croyait que je voulais calculer les vraies valeurs propres, ce qui était correct à l'époque, mais maintenant je cherche à calculer des valeurs propres complexes, ce que mon code ne fait évidemment pas, et je ne sais pas par où commencer. Quelqu'un a-t-il des suggestions? Un CAS sera-t-il nécessaire pour cela ? J'ai examiné les CAS disponibles et s'il était possible de porter SymPy sur microPython, mais j'ai abandonné assez rapidement.
Lephenixnoir Hors ligne Administrateur Points: 24145 Défis: 170 Message

Citer : Posté le 28/10/2021 16:05 | #


Je ne crois pas qu'il existe de solveur complexe en Basic, mais Thebigbadboy me contredira peut-être (ou aura peut-être une astuce algébrique).

Pour ce qui est de porter SymPy sur MicroPython, déjà sur ordinateur ce serait faramineux, sur une calculatrice juste pas possible.
Mon graphe (24 Mars): (gint#27 ; (Rogue Life || HH2) ; PythonExtra ; serial gint ; Boson X ; ...) || (shoutbox v5 ; v5)
Thebigbadboy Hors ligne Maître du Puzzle Points: 455 Défis: 16 Message

Citer : Posté le 01/11/2021 15:27 | #


Timothy529 a écrit :
Maintenant je cherche à calculer des valeurs propres complexes

Alors ça va être compliqué

Comme l'a dit LephenixNoir, il n'y a pas de solveur complexe en Basic Casio (bien que le menu Équation permet de résoudre - avec des réponses complexes - des polynômes d'au plus 6 degrés).

Si j'ai bien compris, tu recherches absolument toutes les valeurs propres (réelles et complexes). Si c'est bien le cas, j'irais voir du côté de la décomposition QR (méthode itérative). En gros, R est triangulaire supérieure et comprend sur sa diagonale les valeurs propres (tandis que Q les vecteurs propres associés).
Et si la matrice donnée a des valeurs propres complexes, on a un "petit morceau qui dépasse en dessous de la diagonale" (je sais pas expliquer je sais ). Par exemple la matrice R suivante
   21.3589   -5.6678   10.0809   -2.3429   -5.0900
         0   -1.9810    8.7273   -6.2583   -3.8582
         0   -5.1169   -1.9810   -0.3539   -1.8999
         0         0         0    1.2580   -0.3232
         0         0         0         0    4.3450

a les valeurs propres 4.3, 1.25, 21.35. Et pour avoir les valeurs propres complexes, il faudrait trouver les valeurs propres de la simple matrice
-1.9810    8.7273
-5.1169   -1.9810


Au final, la décomposition QR a 2 avantages : donne absolument toutes les valeurs propres (contrairement à SolveN qui peut être négligeable des fois et oublier des réponses), et fait une sorte de "diviser pour mieux régner"

Malgré tout, je m'arrête là pour l'instant. Cette année-ci j'ai un cours spécialement pour calculer numériquement les valeurs propres (donc je donnerai des nouvelles/implémentations sûrement bientôt si ça peut aider).
Il peut être utile aussi de rappeler que chercher les valeurs propres revient à chercher les solutions d'un polynôme. Peut-être y aurait-il moyen d'utiliser les fonctions du menu Équation en programmation (même si ça m'étonnerait) ?

J'ai déjà quelques idées en tête, mais je ne préfère pas m'avancer trop par manque de connaissance (et je ne sais pas non plus si elles pourraient aboutir). Il ne faut pas hésiter à aller voir d'autres algos de recherche, comme la méthode de la puissance ne renvoyant que la val propre de plus grand module (qui donne par conséquent une 2e valeur propre - conjuguée - si celle-ci est complexe).

Bref, ce que tu demandes ici est un gros challenge
Un problème sans solution est un problème mal posé — Albert Einstein
Timothy529 Hors ligne Membre Points: 32 Défis: 0 Message

Citer : Posté le 11/11/2021 16:31 | #


Hello, I am working on orthogonal basis programs now, and I'm wondering if there is any way to display the exact radicals of square roots in the program rather than the decimal equivalents. I doubt it but it would save having to exit the program to do it in RunMat
Gladosse Hors ligne Membre Points: 229 Défis: 2 Message

Citer : Posté le 11/11/2021 17:39 | #


Timothy529 a écrit :
Hello, I am working on orthogonal basis programs now, and I'm wondering if there is any way to display the exact radicals of square roots in the program rather than the decimal equivalents. I doubt it but it would save having to exit the program to do it in RunMat

"√"+your number, you can find the square root character in the char menu using f5 on the program editor
Timothy529 Hors ligne Membre Points: 32 Défis: 0 Message

Citer : Posté le 11/11/2021 17:59 | #


Gladosse a écrit :

"√"+your number, you can find the square root character in the char menu using f5 on the program editor

All the output I've gotten from "√" in programs is decimal numbers. I'm wondering if there is a way to display it in simplist radical form, like it does in RunMat for roots of numbers under 1000. I'm also looking to display fractions rather than decimals.
Gladosse Hors ligne Membre Points: 229 Défis: 2 Message

Citer : Posté le 12/11/2021 19:48 | #


Timothy529 a écrit :

All the output I've gotten from "√" in programs is decimal numbers. I'm wondering if there is a way to display it in simplist radical form, like it does in RunMat for roots of numbers under 1000. I'm also looking to display fractions rather than decimals.


you shouldn't use the sqrt function in your calculator, but rather the character associated to the square root symbol, which you can find by pressing f5 in the program editor, it's essentially the same as adding a letter next to your number, just click on the sqrt symbol, and then use it to display that character next to your variable or number using locate, it'll display it as the radical form

char window :

code :

output :


so asked it to display the character √ on (1;1), and my number on (2;1)
hope that cleared things out
Lephenixnoir Hors ligne Administrateur Points: 24145 Défis: 170 Message

Citer : Posté le 12/11/2021 19:53 | #


I think you can do that by placing the normal sqrt symbol in quotes too.

As far as I know, you can't have symbolic square roots in variables. I think you can have fractions by using the frac symbol/key, but I don't know how convenient it is to use. The general idea is no symbolic calculus in PRGM.
Mon graphe (24 Mars): (gint#27 ; (Rogue Life || HH2) ; PythonExtra ; serial gint ; Boson X ; ...) || (shoutbox v5 ; v5)
Timothy529 Hors ligne Membre Points: 32 Défis: 0 Message

Citer : Posté le 13/12/2021 21:04 | # | Fichier joint


I just wanted to make a final update here and say thanks to everyone that helped me here, especially Lephenixnoir. I am happy to say I passed my Linear Algebra Class with a 92 average, and a 92 on the final. I will upload the final file with all my programs in case it could help someone in the future. I ended up making an aTools program that links to the subdivisions of tools I made. There's two main sides to it, LAHelper, and VctHelp. VctHelp uses vectors stored as lists to calculate orthoganal projections, gram schmidt orthoganal basis, and other tools. Again, thanks to everyone here. This entire community around Casio Calculators and my journey to finding the answers I needed was quite the process, but I'm glad I did it. Cheers.
Lephenixnoir Hors ligne Administrateur Points: 24145 Défis: 170 Message

Citer : Posté le 13/12/2021 21:10 | #


Congratulations! We're happy to see you passed with such a high score. If you have a few minutes to spare I suggest posting your code as an actual program so it's more visible to other users.
Mon graphe (24 Mars): (gint#27 ; (Rogue Life || HH2) ; PythonExtra ; serial gint ; Boson X ; ...) || (shoutbox v5 ; v5)
Thebigbadboy Hors ligne Maître du Puzzle Points: 455 Défis: 16 Message

Citer : Posté le 25/03/2022 00:50 | #


I know it's been a while

Congrats for your exam !

You remember I said that, perhaps, I would write a prog to compute all eigenvalues of a given matrix ?
I was quite busy (well, seems like it's always the case, so surely my time management is slammed to the ground - french expression haha).
So during my playtime I managed to write a "beta" prog, using the QR algorithm explained previously.

The algorithm I wrote works really well, and computes all eigenvalues (real and complex) of (almost) any real matrix. I'm not currently sharing it, since there is one problem : "orthogonal-like" matrices make that the QR algorithm does not converge (see my thread at math.stackexchange).

Well, if anyone want it already (don't hesitate to ask !), I can of course publish it (I'm trying to not upload as many updates as my prog "Calcul Limites" ). But the fact is QR algorithm is therefore not the way to go (probably). I'll dig in another iterative algorithms, but the number of papers we can found online is absolutly pharaonic

Stay tuned !
Un problème sans solution est un problème mal posé — Albert Einstein
1, 2 Suivante

LienAjouter une imageAjouter une vidéoAjouter un lien vers un profilAjouter du codeCiterAjouter un spoiler(texte affichable/masquable par un clic)Ajouter une barre de progressionItaliqueGrasSoulignéAfficher du texte barréCentréJustifiéPlus petitPlus grandPlus de smileys !
Cliquez pour épingler Cliquez pour détacher Cliquez pour fermer
Alignement de l'image: Redimensionnement de l'image (en pixel):
Afficher la liste des membres
:bow: :cool: :good: :love: ^^
:omg: :fusil: :aie: :argh: :mdr:
:boulet2: :thx: :champ: :whistle: :bounce:
valider
 :)  ;)  :D  :p
 :lol:  8)  :(  :@
 0_0  :oops:  :grr:  :E
 :O  :sry:  :mmm:  :waza:
 :'(  :here:  ^^  >:)

Σ π θ ± α β γ δ Δ σ λ
Veuillez donner la réponse en chiffre
Vous devez activer le Javascript dans votre navigateur pour pouvoir valider ce formulaire.

Si vous n'avez pas volontairement désactivé cette fonctionnalité de votre navigateur, il s'agit probablement d'un bug : contactez l'équipe de Planète Casio.

Planète Casio v4.3 © créé par Neuronix et Muelsaco 2004 - 2024 | Il y a 79 connectés | Nous contacter | Qui sommes-nous ? | Licences et remerciements

Planète Casio est un site communautaire non affilié à Casio. Toute reproduction de Planète Casio, même partielle, est interdite.
Les programmes et autres publications présentes sur Planète Casio restent la propriété de leurs auteurs et peuvent être soumis à des licences ou copyrights.
CASIO est une marque déposée par CASIO Computer Co., Ltd