subst cmd

Messages in english

Modérateur : xcasadmin

Répondre
compsystems
Messages : 603
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

subst cmd

Message par compsystems » sam. juil. 13, 2024 7:30 pm

Hi
subst(a*x^2+b*x+c, a = -6,b = -4,c = 2); [ENTER] returns "Error: too many arguments: subst" ?

but

subst(a^2+b,a=2,b=1) ; [ENTER] returns 5

XcasEngGuy
Messages : 160
Inscription : mer. janv. 13, 2010 3:20 pm

Re: subst cmd

Message par XcasEngGuy » mer. juil. 17, 2024 5:20 pm

Use:

subst(a*x^2+b*x+c, [a = -6,b = -4,c = 2]); [ENTER]

then you can have as many as you want

compsystems
Messages : 603
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: subst cmd

Message par compsystems » dim. juil. 28, 2024 7:19 pm

Hi, but if it works for 2 vars a=2,b=1 without listing it [a=2,b=1], it should work for more arguments,

I don't see the need to add [ , , ]

belanger
Messages : 63
Inscription : jeu. juil. 27, 2017 3:26 pm

Re: subst cmd

Message par belanger » lun. juil. 29, 2024 9:02 am

The documentation says that the subst command takes two or three arguments. The third argument is intended to hold a value (or list of values).
I would guess that through a quirk of programming the third argument can be used for another equation, but this wasn't intended. Since subst can't take more than three arguments, this quirk doesn't apply for more than two equations.

XcasEngGuy
Messages : 160
Inscription : mer. janv. 13, 2010 3:20 pm

Re: subst cmd

Message par XcasEngGuy » mer. juil. 31, 2024 5:26 pm

I use "quote" as the third argument (without quote marks) to substitute without simplification. This is very useful for teaching, as it is more like algebra done on paper. Is there some other intended use?
Dernière modification par XcasEngGuy le mer. juil. 31, 2024 5:39 pm, modifié 1 fois.

XcasEngGuy
Messages : 160
Inscription : mer. janv. 13, 2010 3:20 pm

Re: subst cmd

Message par XcasEngGuy » mer. juil. 31, 2024 5:37 pm

By the way, I usually collect my initial parameters in an array which means I can substitute them all at once into an equation by simply referencing the array name in the 2nd argument to subst. I also do this with solved variables as I progress in a solution. For example:

eq1:=tran(x1=5.368,y1=2.294,x2=8.064,y2=2.294)

\begin{equation} \label{eq:1}
\left[\begin{array}{c}x_{1}=5.368\\y_{1}=2.294\\x_{2}=8.064\\y_{2}=2.294\\\end{array}\right]
\end{equation}

subst(eq2,eq1)

belanger
Messages : 63
Inscription : jeu. juil. 27, 2017 3:26 pm

Re: subst cmd

Message par belanger » jeu. août 01, 2024 2:12 am

Oh!
Neither the English nor the French manual mentions using "quote" as a third argument; that should probably be fixed.
Also, "help(subst)" actually gives an example where both the second and third arguments are equations. As compsystems points out, that would violate the 0,1,infinity rule. But I suppose it's an undocumented feature, not a bug??

XcasEngGuy
Messages : 160
Inscription : mer. janv. 13, 2010 3:20 pm

Re: subst cmd

Message par XcasEngGuy » sam. août 03, 2024 2:36 am

I know it was recently added. I found out about it here after I asked a question

viewtopic.php?f=19&t=2867

Matt

belanger
Messages : 63
Inscription : jeu. juil. 27, 2017 3:26 pm

Re: subst cmd

Message par belanger » mer. août 21, 2024 7:31 pm

For what it's worth, here is a small patch to update the documentation cascmd_en.tex.
(It's a text file, but I had to add the pdf extension to upload it.)
Pièces jointes
cascmd_en.patch.pdf
(1.19 Kio) Téléchargé 528 fois

parisse
Messages : 5879
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: subst cmd

Message par parisse » jeu. août 22, 2024 1:55 pm

Thank you!

Répondre