login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for SandBox Solve revision 6 of 7

1 2 3 4 5 6 7
Editor: Xenon
Time: 2009/03/15 13:13:12 GMT-7
Note: test

added:

From Xenon Sun Mar 15 13:13:12 -0700 2009
From: Xenon
Date: Sun, 15 Mar 2009 13:13:12 -0700
Subject: test
Message-ID: <20090315131312-0700@axiom-wiki.newsynthesis.org>

solve(x^2 + 2 = 0, x)

Solving Equations

What method is used to solve equation in Axiom?

axiom
solve(sin(x)=4/5,x)

\label{eq1}\left[{x ={\arcsin \left({4 \over 5}\right)}}\right](1)
Type: List(Equation(Expression(Integer)))
axiom
solve([a=4,sin(x)=a/5],[a,x])

\label{eq2}\left[{\left[ \right]}\right](2)
Type: List(List(Equation(Expression(Integer))))

In the following, a workaround is necessary because of bug #128:

axiom
)set output algebra on
 
axiom
)set output tex off
solve([V_q*U_q+V_l*U_l+V_d*U_d+V_a*U_a=U_ma, _ V_q*rho_q+V_l*rho_l+ V_d*rho_d+V_a*rho_a=rho_ma,i _ V_q*t_q+V_l*t_l+V_d*t_d+V_a*t_a=t_ma, _ V_q+V_l+V_d+V_a=1], _ [V_q,V_l,V_d,V_a] )
There are no library operations named i Use HyperDoc Browse or issue )what op i to learn if there is any operation containing " i " in its name.
Cannot find a definition or applicable library operation named i with argument type(s) Variable(Vq)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.
axiom
)set output algebra off
 
axiom
)set output tex on

axiom
solve(v^4+b*v^3+c*v^2+d=0,v)

\label{eq3}\left[{{{v^4}+{b \ {v^3}}+{c \ {v^2}}+ d}= 0}\right](3)
Type: List(Equation(Fraction(Polynomial(Integer))))

This didn't work since solve returns solutions expressible as members of the ground field only. Above, the ground field of v^4+b<em>v^3+c</em>v^2+d defaults to Fraction Polynomial Integer...

Thus, the proper call is

axiom
solve((v^4+b*v^3+c*v^2+d)::EXPR INT=0,v)

\label{eq4}\begin{array}{@{}l}
\displaystyle
\left[{v = \%v 0}, \:{v = \%v 1}, \: \right.
\
\
\displaystyle
\left.{
\begin{array}{@{}l}
\displaystyle
v ={{\left(
\begin{array}{@{}l}
\displaystyle
{\sqrt{-{3 \ {\%v 1^2}}+{{\left(-{2 \  \%v 0}-{2 \  b}\right)}\  \%v 1}-{3 \ {\%v 0^2}}-{2 \  b \  \%v 0}-{4 \  c}+{b^2}}}- 
\
\
\displaystyle
\%v 1 - \%v 0 - b 
(4)
Type: List(Equation(Expression(Integer)))

But really, you should use 'zerosOf':

axiom
zerosOf(v^4+b*v^3+c*v^2+d, v)

\label{eq5}\begin{array}{@{}l}
\displaystyle
\left[ \%v 8, \: \%v 9, \: \right.
\
\
\displaystyle
\left.{{\left(
\begin{array}{@{}l}
\displaystyle
{\sqrt{-{3 \ {\%v 9^2}}+{{\left(-{2 \  \%v 8}-{2 \  b}\right)}\  \%v 9}-{3 \ {\%v 8^2}}-{2 \  b \  \%v 8}-{4 \  c}+{b^2}}}- 
\
\
\displaystyle
\%v 9 - \%v 8 - b 
(5)
Type: List(Expression(Integer))

In the following, we have to do three things:

  • convert the list of Fraction Polynomial Float to a list of Fraction Polynomial Integer, since solve can only handle the latter,
  • ask for an approximate solution and
  • set precision to a lower value then 68, since it would take too much time otherwise

Furthermore, it's %pi, not %PI. Finally, the underscore is the escape character (like \) and is also used as the the line continuation character when it occurs at the end of th line. So K_sc is equivalent to just Ksc, but K__sc is actually K_sc.

Here is one way to use macros and _ to define more complex names that print nicely in LaTeX? form:

axiom
K_sc  ==> K___{sc_}
Type: Void
axiom
mu_sc ==> _\mu___{sc_}
Type: Void

axiom
digits(7);
Type: PositiveInteger?
axiom
l:=  [0.01*(2.25-K_sc)*K_sc/(0.01*%pi*mu_sc*(mu_sc+3.0*K_sc)/                         _
      (4.0*mu_sc+3.0*K_sc)+2.25)+0.7*(37.0-K_sc)*(4.0*mu_sc/3.0+K_sc)/                _
      (4.0*mu_sc/3.0+37.0)+0.29*(2.25-K_sc)*(4.0*mu_sc/3.0+K_sc)/                     _
      (4.0*mu_sc/3.0+2.25),                                                           _
      -0.002*mu_sc*(2.0*(2.0*mu_sc/3.0+2.25)/                                         _
      (0.01*%pi*mu_sc*(mu_sc+3.0*K_sc)/                                               _
      (4.0*mu_sc+3.0*K_sc)+2.25)+800.0*mu_sc/                                         _
      (%pi*(2.0*mu_sc*(mu_sc+3.0*K_sc)/                                               _
      (4.0*mu_sc+3.0*K_sc)+mu_sc))+1.0)+0.7*(44.0-mu_sc)*(mu_sc*(8.0*mu_sc+9.0*K_sc)/ _
      (6.0*(2.0*mu_sc+K_sc))+mu_sc)/                                                  _
      (mu_sc*(8.0*mu_sc+9.0*K_sc)/                                                    _
      (6.0*(2.0*mu_sc+K_sc))+44.0)-1.74*(2.0*mu_sc+K_sc)*(mu_sc*(8.0*mu_sc+9.0*K_sc)/ _
      (6.0*(2.0*mu_sc+K_sc))+mu_sc)/(8.0*mu_sc+9.0*K_sc)]

\label{eq6}\begin{array}{@{}l}
\displaystyle
\left[{{\left(
\begin{array}{@{}l}
\displaystyle
{{\left(-{{0.99}\  K_{sc}}+{26.5525}\right)}\ {\mu_{sc}^4}}+ \
\
\displaystyle
{{\left({
\begin{array}{@{}l}
\displaystyle
-{{4.98574}\ {K_{sc}^2}}-{{190.4062}\  K_{sc}}+ 
\
\
\displaystyle
{7668.544}
(6)
Type: List(Fraction(Polynomial(Float)))
axiom
-- solve exactly for fractions
a:=solve (l::LIST FRAC POLY FRAC INT::LIST FRAC POLY INT);
Type: List(List(Equation(Fraction(Polynomial(Integer)))))
axiom
-- Number of results:
#a

\label{eq7}2(7)
Type: PositiveInteger?
axiom
-- But only the first one is of interest.
-- Display it as a floating point result
a.1::List Equation Fraction POLY FLOAT

\label{eq8}\left[{\mu_{sc}={0.0}}, \:{K_{sc}={6.568047}}\right](8)
Type: List(Equation(Fraction(Polynomial(Float))))
axiom
-- Now check it
map(x+->subst(x,(a.1)::List Equation FRAC POLY FLOAT),l)

\label{eq9}\left[{0.0}, \:{0.0}\right](9)
Type: List(Expression(Float))

axiom
)clear all
All user variables and function definitions have been cleared.

axiom
solve((x=-1+x^2)::EQ EXPR INT,x)

\label{eq10}\left[{x ={{{\sqrt{5}}+ 1}\over 2}}, \:{x ={{-{\sqrt{5}}+ 1}\over 2}}\right](10)
Type: List(Equation(Expression(Integer)))

quadratic equation

axiom
solve(a*x^2+b*x+c=0,x)

\label{eq11}\left[{{{a \ {x^2}}+{b \  x}+ c}= 0}\right](11)
Type: List(Equation(Fraction(Polynomial(Integer))))

axiom
solve(a*x+b=0,x)

\label{eq12}\left[{x = -{b \over a}}\right](12)
Type: List(Equation(Fraction(Polynomial(Integer))))

quadratic equation

axiom
solve(x**2+x-1,x)

\label{eq13}\left[{{{x^2}+ x - 1}= 0}\right](13)
Type: List(Equation(Fraction(Polynomial(Integer))))

axiom
radicalSolve(a*x**2+b*x+c=0,x)

\label{eq14}\left[{x ={{-{\sqrt{-{4 \  a \  c}+{b^2}}}- b}\over{2 \  a}}}, \:{x ={{{\sqrt{-{4 \  a \  c}+{b^2}}}- b}\over{2 \  a}}}\right](14)
Type: List(Equation(Expression(Integer)))

This doesn't work on mine michen:
axiom
L := [ A = 2*P1+P2, B = 2*P2+P1, C = 2*Q1+Q2, D = 2*Q2+Q1]

\label{eq15}\begin{array}{@{}l}
\displaystyle
\left[{A ={P 2 +{2 \  P 1}}}, \:{B ={{2 \  P 2}+ P 1}}, \:{C ={Q 2 +{2 \  Q 1}}}, \: \right.
\
\
\displaystyle
\left.{D ={{2 \  Q 2}+ Q 1}}\right] 
(15)
Type: List(Equation(Polynomial(Integer)))
axiom
solve(L, [P1,P2])

\label{eq16}\left[ \right](16)
Type: List(List(Equation(Fraction(Polynomial(Integer)))))

But it should, observe this:

axiom
solve([L.1,L.2],[P1,P2])

\label{eq17}\left[{\left[{P 1 ={{- B +{2 \  A}}\over 3}}, \:{P 2 ={{{2 \  B}- A}\over 3}}\right]}\right](17)
Type: List(List(Equation(Fraction(Polynomial(Integer)))))
axiom
solve([L.3,L.4],[Q1,Q2])

\label{eq18}\left[{\left[{Q 1 ={{- D +{2 \  C}}\over 3}}, \:{Q 2 ={{{2 \  D}- C}\over 3}}\right]}\right](18)
Type: List(List(Equation(Fraction(Polynomial(Integer)))))

First two equationa do not depend on Q_i, the later two don't depend on P_i.

axiom
)set output algebra on
 
axiom
)set output tex off
radicalSolve(a*x**3+b*x**2+c*x+d=0,x)
(10) [ x = 2 +---+ 2 (- 9a \|- 3 + 9a ) * ROOT +------------------------------------------+ | 2 2 3 3 2 2 3 |27a d + (- 18a b c + 4b )d + 4a c - b c 2 54a |------------------------------------------ - 27a d | 4 \| 108a + 3 9a b c - 2b / 3 54a , 3 ^ 2 + +---+ (- 3a b\|- 3 - 3a b) * ROOT +------------------------------------------+ | 2 2 3 3 2 2 3 |27a d + (- 18a b c + 4b )d + 4a c - b c 2 54a |------------------------------------------ - 27a d | 4 \| 108a + 3 9a b c - 2b / 3 54a , 3 + 2 6a c - 2b / 2 +---+ 2 (9a \|- 3 + 9a ) * ROOT +------------------------------------------+ | 2 2 3 3 2 2 3 |27a d + (- 18a b c + 4b )d + 4a c - b c 2 54a |------------------------------------------ - 27a d | 4 \| 108a + 3 9a b c - 2b / 3 54a , 3 ,
x = 2 +---+ 2 (- 9a \|- 3 - 9a ) * ROOT +------------------------------------------+ | 2 2 3 3 2 2 3 |27a d + (- 18a b c + 4b )d + 4a c - b c 2 54a |------------------------------------------ - 27a d | 4 \| 108a + 3 9a b c - 2b / 3 54a , 3 ^ 2 + +---+ (- 3a b\|- 3 + 3a b) * ROOT +------------------------------------------+ | 2 2 3 3 2 2 3 |27a d + (- 18a b c + 4b )d + 4a c - b c 2 54a |------------------------------------------ - 27a d | 4 \| 108a + 3 9a b c - 2b / 3 54a , 3 + 2 - 6a c + 2b / 2 +---+ 2 (9a \|- 3 - 9a ) * ROOT +------------------------------------------+ | 2 2 3 3 2 2 3 |27a d + (- 18a b c + 4b )d + 4a c - b c 2 54a |------------------------------------------ - 27a d | 4 \| 108a + 3 9a b c - 2b / 3 54a , 3 ,
x = 2 9a * ROOT +------------------------------------------+ | 2 2 3 3 2 2 3 |27a d + (- 18a b c + 4b )d + 4a c - b c 2 54a |------------------------------------------ - 27a d | 4 \| 108a + 3 9a b c - 2b / 3 54a , 3 ^ 2 + - 3a b * ROOT +------------------------------------------+ | 2 2 3 3 2 2 3 |27a d + (- 18a b c + 4b )d + 4a c - b c 2 54a |------------------------------------------ - 27a d | 4 \| 108a + 3 9a b c - 2b / 3 54a , 3 + 2 - 3a c + b / 2 9a * ROOT +------------------------------------------+ | 2 2 3 3 2 2 3 |27a d + (- 18a b c + 4b )d + 4a c - b c 2 54a |------------------------------------------ - 27a d | 4 \| 108a + 3 9a b c - 2b / 3 54a , 3 ]
Type: List(Equation(Expression(Integer)))
axiom
)set output algebra off
 
axiom
)set output tex on

axiom
solve(sin(x)=4/5,x)

\label{eq19}\left[{x ={\arcsin \left({4 \over 5}\right)}}\right](19)
Type: List(Equation(Expression(Integer)))

axiom
solve(x^2=y,x)

\label{eq20}\left[{{y -{x^2}}= 0}\right](20)
Type: List(Equation(Fraction(Polynomial(Integer))))

Use braces { } not parenthesis ( )
axiom
solve(x3=x0+(x1-x0)*t + (x2-x0) *u,u)

\label{eq21}\left[{u ={{x 3 -{t \  x 1}+{{\left(t - 1 \right)}\  x 0}}\over{x 2 - x 0}}}\right](21)
Type: List(Equation(Fraction(Polynomial(Integer))))

axiom
solve([x+y=3,x-y=1],[x,y])

\label{eq22}\left[{\left[{x = 2}, \:{y = 1}\right]}\right](22)
Type: List(List(Equation(Fraction(Polynomial(Integer)))))

An error in the way MathAction? folds the LaTeX? output from Axiom prevents this expression from displaying properly. As a work-a-round it is necessary to disable the LaTeX? output and replace it with a ASCII text equivalent.

axiom
)set output tex off
 
axiom
)set output algebra on
A:=i=(a*x+c*z+e)/(z+g)
c z + a x + e (15) i= ------------- z + g
Type: Equation(Fraction(Polynomial(Integer)))
axiom
B:=j=(b*x+d*z+f)/(z+g)
d z + b x + f (16) j= ------------- z + g
Type: Equation(Fraction(Polynomial(Integer)))
axiom
solve([A,B],[x,z])
(17) (c g - e)j + (- d g + f)i - c f + d e - a g j + b g i + a f - b e [[x= -------------------------------------,z= ---------------------------]] a j - b i - a d + b c a j - b i - a d + b c
Type: List(List(Equation(Fraction(Polynomial(Integer)))))
axiom
)set output tex on
 
axiom
)set output algebra off

axiom
solve(sin(x)=4/5,x)

\label{eq23}\left[{x ={\arcsin \left({4 \over 5}\right)}}\right](23)
Type: List(Equation(Expression(Integer)))

axiom
L := [ A = 2*P1+P2, B = 2*P2+P1, C = 2*Q1+Q2, D = 2*Q2+Q1]
There are 3 exposed and 0 unexposed library operations named equation having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op equation to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named equation with argument type(s) Equation(Fraction(Polynomial(Integer))) Polynomial(Integer)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. solve(L, [P1,P2])

\label{eq24}\left[ \right](24)
Type: List(List(Equation(Fraction(Polynomial(Integer)))))

axiom
solve(14=x*1.1^x,x)
There are 18 exposed and 3 unexposed library operations named solve having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op solve to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named solve with argument type(s) Equation(Expression(Float)) Variable(x)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

--I don't know --tempo, Thu, 15 Mar 2007 14:15:26 -0600 reply
axiom
)set output algebra on
 
axiom
)set output tex off
zerosOf((1-a)*x^4+x^3+x^2+x+1,x)
(20) [%x10, %x11,
- ROOT 2 2 2 (- 3a + 6a - 3)%x11 + ((- 2a + 4a - 2)%x10 + 2a - 2)%x11 + 2 2 (- 3a + 6a - 3)%x10 + (2a - 2)%x10 + 4a - 3 + (- a + 1)%x11 + (- a + 1)%x10 + 1 / 2a - 2 ,
ROOT 2 2 2 (- 3a + 6a - 3)%x11 + ((- 2a + 4a - 2)%x10 + 2a - 2)%x11 + 2 2 (- 3a + 6a - 3)%x10 + (2a - 2)%x10 + 4a - 3 + (- a + 1)%x11 + (- a + 1)%x10 + 1 / 2a - 2 ]
Type: List(Expression(Integer))
axiom
)set output algebra off
 
axiom
)set output tex on

test --faceinjarbydoor, Tue, 22 May 2007 13:53:38 -0500 reply
axiom
solve( dx_p = ( m / b ) * ( c0 - b * dv_p + c0 * log(c0) -     _
              c0 * log( c0 - b * dv_p ) + v0 * log(c0) -       _
              v0 * log( c0 - b * dv_p ) - ( c0 / b ) ), dv_p )

\label{eq25}\left[ \right](25)
Type: List(Equation(Expression(Integer)))

axiom
solve(((1+sqrt(5))^n-(1-sqrt(5))^n)/(sqrt(5)*2^n)=10^1001, n)

\label{eq26}\left[ \right](26)
Type: List(Equation(Expression(Integer)))

hw problem! --hintzy64, Sun, 14 Oct 2007 21:47:27 -0500 reply
axiom
)set output tex off
 
axiom
)set output algebra on

axiom
solve([nnH+2*niH+nnCs+2*niCs = n, (niH+niCs)*niH/nnH = SH, (niH+niCs)*niCs/nnCs = SCs, (niH+nnH)/(niCs+nnCs) = alpha],[nnH, niH, nnCs, niCs])
(23) [ [ nnH = 2 2 ((- 2SH + 2SCs)alpha + (- 3SH + 3SCs)alpha - SH + SCs)niCs + 2 2 2 (- 2SH alpha + (- SH - SCs)alpha)n + (- 4SCs SH + 2SCs )alpha + 2 2 (- 6SCs SH + 4SCs )alpha - 2SCs SH + 2SCs * niCs + 2 2 2 SCs alpha n + ((2SCs SH - SCs )alpha + SCs SH - SCs )n / 2 2 (SCs alpha + SCs)n + SCs alpha + SCs ,
niH = 2 ((SH - SCs)alpha + SH - SCs)niCs + 2 2 (SH alpha n + (2SCs SH - SCs )alpha + 2SCs SH - 2SCs )niCs + 2 (- SCs SH + SCs )n / 2 SCs n + SCs ,
nnCs = 2 ((- SH + SCs)alpha - SH + SCs)niCs + (((- SH - SCs)alpha - 2SCs)n - 2SCs SH alpha - 2SCs SH)niCs + 2 SCs n + SCs SH n / 2 2 (SCs alpha + SCs)n + SCs alpha + SCs ,
2 3 ((SH - SCs)alpha + (2SH - 2SCs)alpha + SH - SCs)niCs + 2 2 2 (SH alpha + (SH + SCs)alpha + SCs)n + (2SCs SH - SCs )alpha + 2 2 (5SCs SH - 3SCs )alpha + 3SCs SH - 2SCs * 2 niCs + 2 2 2 2 2 2 ((2SCs alpha - SCs SH + 3SCs )n + 2SCs SH alpha + 2SCs SH)niCs - SCs n + 2 - SCs SH n = 0 ] ]
Type: List(List(Equation(Fraction(Polynomial(Integer)))))

solve((-v^3 cos(x) sin(x)^2 / sqrt(v^2 cos(x)^2 + 2ah) - v^2 sin(x)^2 + v cos(x) sqrt(v^2 cos(x)^2 + 2 a h) + v^2 cos(x)^2) / a

axiom
solve((-v^3 * cos(x) * sin(x)^2 / sqrt(v^2 * cos(x)^2 + 2*a*h) - v^2 * sin(x)^2 + v * cos(x) * sqrt(v^2 * cos(x)^2 + 2 * a * h) + v^2 * cos(x)^2) / a
Line 1: solve((-v^3 * cos(x) * sin(x)^2 / sqrt(v^2 * cos(x)^2 + 2*a*h) - v^2 * sin(x)^2 + v * cos(x) * sqrt(v^2 * cos(x)^2 + 2 * a * h) + v^2 * cos(x)^2) / a .....A..............................................................................................................................................B Error A: Missing mate. Error B: syntax error at top level Error B: Possibly missing a ) 3 error(s) parsing

axiom
solve((-v^3 * cos(x) * sin(x)^2 / sqrt(v^2 * cos(x)^2 + 2*a*h) - v^2 * sin(x)^2 + v * cos(x) * sqrt(v^2 * cos(x)^2 + 2 * a * h) + v^2 * cos(x)^2)) / a
>> Error detected within library code: too many variables

axiom
solve((-v^3 * cos(x) * sin(x)^2 / sqrt(v^2 * cos(x)^2 + 2*a*h) - v^2 * sin(x)^2 + v * cos(x) * sqrt(v^2 * cos(x)^2 + 2 * a * h) + v^2 * cos(x)^2) / a)
>> Error detected within library code: too many variables

solve(x^2 + 2 = 0, x)