subst cmd
Modérateur : xcasadmin
-
- Messages : 603
- Inscription : sam. févr. 04, 2017 11:34 pm
- Localisation : Colombia
- Contact :
subst cmd
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
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
-
- Messages : 160
- Inscription : mer. janv. 13, 2010 3:20 pm
Re: subst cmd
Use:
subst(a*x^2+b*x+c, [a = -6,b = -4,c = 2]); [ENTER]
then you can have as many as you want
subst(a*x^2+b*x+c, [a = -6,b = -4,c = 2]); [ENTER]
then you can have as many as you want
-
- Messages : 603
- Inscription : sam. févr. 04, 2017 11:34 pm
- Localisation : Colombia
- Contact :
Re: subst cmd
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 [ , , ]
I don't see the need to add [ , , ]
Re: subst cmd
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.
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.
-
- Messages : 160
- Inscription : mer. janv. 13, 2010 3:20 pm
Re: subst cmd
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.
-
- Messages : 160
- Inscription : mer. janv. 13, 2010 3:20 pm
Re: subst cmd
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)
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)
Re: subst cmd
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??
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??
-
- Messages : 160
- Inscription : mer. janv. 13, 2010 3:20 pm
Re: subst cmd
I know it was recently added. I found out about it here after I asked a question
viewtopic.php?f=19&t=2867
Matt
viewtopic.php?f=19&t=2867
Matt
Re: subst cmd
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.)
(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
Re: subst cmd
Thank you!