When solving a certain system of equations, I have the following:
(%i6) cp[1][1];
3 3 2 3 3 3 2 2 2
(%o6) a11 = (p2 ((2 p1 - 4 p1 ) p3 q4 + (10 p1 - 26 p1 ) p3 p4 q3 q4
3 2 2 2 3 2 3 3
+ (10 p1 - 26 p1 ) p3 p4 q3 q4 + (2 p1 - 4 p1 ) p4 q3 )
3 2 3 2 2 2 2
+ q1 (p2 ((10 p1 - 6 p1) p3 p4 q4 + (32 p1 - 22 p1) p3 p4 q3 q4
2 3 2 2 2 3 2
+ (10 p1 - 6 p1) p3 p4 q3 ) + p2 ((- 4 p1 p3 p4 q4 )
2 2 2 2 3 2
- 16 p1 p3 p4 q3 q4 - 4 p1 p3 p4 q3 )
2 2 3 2 2 2 3
+ q2 (p2 ((32 p1 - 17 p1) p3 p4 q4 + (32 p1 - 17 p1) p3 p4 q3)
2 3 2 2 2 3
+ p2 ((- 11 p1 p3 p4 q4) - 11 p1 p3 p4 q3))
2 3 3 2 3 3 2
+ ((10 p1 - 2 p1) p2 p3 p4 - 3 p1 p3 p4 ) q2 )
2 3 2 3 2 3 2 2 2
+ p2 q2 ((10 p1 - 22 p1 ) p3 p4 q4 + (32 p1 - 110 p1 ) p3 p4 q3 q4
3 2 3 2 2 3
+ (10 p1 - 22 p1 ) p3 p4 q3 ) + q1 (p2
3 2 2 3
((10 p1 - 2) p3 p4 q4 + (10 p1 - 2) p3 p4 q3)
2 3 2 2 3
+ p2 ((- 5 p1 p3 p4 q4) - 5 p1 p3 p4 q3)
2 3 3 3 3
+ ((10 p1 - 1) p2 p3 p4 - 4 p1 p2 p3 p4 ) q2)
2 3 2 3 2 3 2 2 3
+ p2 q2 ((10 p1 - 15 p1 ) p3 p4 q4 + (10 p1 - 15 p1 ) p3 p4 q3)
3 2 3 3 3 3 3 3 2 3 3 3
+ (2 p1 - p1 ) p3 p4 q2 + (2 p2 p3 p4 - p2 p3 p4 ) q1 )
3 3 3 3 3 2 2 3 2 2
/(p2 (2 p1 p3 q4 + 10 p1 p3 p4 q3 q4 + 10 p1 p3 p4 q3 q4
3 3 3 3 2 3 2 2 2 2
+ 2 p1 p4 q3 ) + q1 (p2 (10 p1 p3 p4 q4 + 32 p1 p3 p4 q3 q4
2 3 2 2 2 3 2 2 2 3
+ 10 p1 p3 p4 q3 ) + p2 q2 (32 p1 p3 p4 q4 + 32 p1 p3 p4 q3)
2 3 3 2 2 3 3 2 3 2 2
+ 10 p1 p2 p3 p4 q2 ) + p2 q2 (10 p1 p3 p4 q4 + 32 p1 p3 p4 q3 q4
3 3 2 2 3 3 2 2 3
+ 10 p1 p3 p4 q3 ) + q1 (p2 (10 p1 p3 p4 q4 + 10 p1 p3 p4 q3)
2 3 3 2 3 3 2 3 2 3
+ 10 p1 p2 p3 p4 q2) + p2 q2 (10 p1 p3 p4 q4 + 10 p1 p3 p4 q3)
3 3 3 3 3 3 3 3
+ 2 p1 p3 p4 q2 + 2 p2 p3 p4 q1 )
I would like to isolate the denominator of a11 with the purpose of e.g. factorizing it. How would one go about it?
cp is the solution to a linear system.
Try the functions num and denom to get the numerator and denominator of a ratio, respectively.
In order to get the ratio in %o6 as you showed it, try rhs(%o6).
Related
I have an expression that actually can be expressed in simple form by collecting the specific terms. I have problem in Maxima to substitute or simplify the expression to the known terms.
(%i1) expr:(16*h^2*v_0^2+(38*h*u_0-38*h*u_1)*v_0+25*u_1^2-50*u_0*u_1+25*u_0^2)/3;
2 2 2 2
16 h v_0 + (38 h u_0 - 38 h u_1) v_0 + 25 u_1 - 50 u_0 u_1 + 25 u_0
(%o1) -----------------------------------------------------------------------
3
(%i2) eq1:a1=-h*v_0+2*u_1-2*u_0;
eq2:a2=-2*(h*v_0-u_1+u_0);
(%o2) a1 = (- h v_0) + 2 u_1 - 2 u_0
(%i3)
(%o3) a2 = - 2 (h v_0 - u_1 + u_0)
(%i4) subst([eq1,eq2],expr);
2 2 2 2
16 h v_0 + (38 h u_0 - 38 h u_1) v_0 + 25 u_1 - 50 u_0 u_1 + 25 u_0
(%o4) -----------------------------------------------------------------------
3
What I want is something like this
expr=c1*(a1)^q1 + c2*(a2)^q2
where c1,c2,q1,q2 are the constant that would generated by simplifying expr using known term a1,a2. How to do that? Is there any specific syntax?
I have a function in Maxima I am differentiating then attempting to find the value at which this is zero. When I use solve(), however, I am not given a solution. Why is this, and how can I work around it?
(%i1) f(x):=(-5*(x^4+5*x^3-3*x))/(x^2+1);
(%o1) f(x):=((-5)*(x^4+5*x^3+(-3)*x))/(x^2+1)
(%i2) df(x):=''(diff(f(x), x));
(%o2) df(x):=(10*x*(x^4+5*x^3-3*x))/(x^2+1)^2-(5*(4*x^3+15*x^2-3))/(x^2+1)
(%i3) solve(df(x), x);
(%o3) [0=2*x^5+5*x^4+4*x^3+18*x^2-3]
The function solve is not too strong; there are many problems it can't solve. A stronger version is under development. In the meantime, try the add-on package to_poly_solve. Here's what I get:
(%i1) df(x) := (10*x*(x^4+5*x^3-3*x))/(x^2+1)^2-(5*(4*x^3+15*x^2-3))/(x^2+1) $
(%i2) load (to_poly_solve) $
(%i3) to_poly_solve (df(x), x);
(%o3) %union([x = - 2.872468527640942], [x = - 0.4194144025323134],
[x = 0.3836388367122223], [x = 0.2041221431132173 - 1.789901606296292 %i],
[x = 1.789901606296292 %i + 0.2041221431132173])
Something which is maybe a little surprising is that to_poly_solve has returned a numerical solution instead of exact or symbolic. Tracing allroots shows that to_poly_solve has constructed a quintic equation and punted it to allroots. Since the general quintic doesn't have a solution in terms of radicals, and even in special cases it's probably very messy, maybe it's most useful to have a numerical solution anyway.
Try plot2d(df(x), [x, -3, 1]) to visualize the real roots returned above.
You can try to find a numerical solution. I don't know why solve does not try this. Either you take the ouput of aolveor you do hte folölowing:
(%i1) f(x):=(-5*(x^4+5*x^3-3*x))/(x^2+1);
4 3
(- 5) (x + 5 x + (- 3) x)
(%o1) f(x) := ---------------------------
2
x + 1
(%i2) df(x):=''(diff(f(x), x));
4 3 3 2
10 x (x + 5 x - 3 x) 5 (4 x + 15 x - 3)
(%o2) df(x) := ---------------------- - --------------------
2 2 2
(x + 1) x + 1
Bring it to a common denominator and extract the numerator:
(%i3) xthru(df(x));
4 3 2 3 2
10 x (x + 5 x - 3 x) - 5 (x + 1) (4 x + 15 x - 3)
(%o3) ------------------------------------------------------
2 2
(x + 1)
(%i4) num(%);
4 3 2 3 2
(%o4) 10 x (x + 5 x - 3 x) - 5 (x + 1) (4 x + 15 x - 3)
use allsrootsto find the roots of a polynomial numerically
(%i5) allroots(%);
(%o5) [x = 0.3836388391066617, x = - 0.4194143906217701,
x = 1.789901606296292 %i + 0.2041221431132174,
x = 0.2041221431132174 - 1.789901606296292 %i, x = - 2.872468734711326]
skip the complex solutions
(%i6) sublist(%,lambda([t],imagpart(rhs(t))=0))
;
(%o6) [x = 0.3836388391066617, x = - 0.4194143906217701,
x = - 2.872468734711326]
How to expand taylor series/polynomials about Q=0 , and then extract coefficients as a list
example :
taylor ( (sin(q)), q, 0, 9); //taylor expansion for first 9 terms gives the next line
(%o1)/T/ q\-q^3/6+q^5/120\-q^7/5040+q^9/362880+...
then using coeff ((%o1), q ^n); gives me the coefficient at n only, what i want is a list for all the coefficients of that expression
Try coeff plus makelist, e.g. something like: makelist(coeff(%o1, q, n), n, 0, 9);
Edit:
I see now that I misread your question and there is already an answer. Nevertheless I will keep it because it is related to your question.
Use powerseries instead of taylor:
(%i1) expr:powerseries(sin(x),x,0);
inf
==== i2 2 i2 + 1
\ (- 1) x
(%o1) > -----------------
/ (2 i2 + 1)!
====
i2 = 0
You can access the coefficient by the args or part function
(%i2) op(expr);
(%o2) sum
(%i3) args(expr);
i2 2 i2 + 1
(- 1) x
(%o3) [-----------------, i2, 0, inf]
(2 i2 + 1)!
(%i4) part(expr,1);
i2 2 i2 + 1
(- 1) x
(%o4) -----------------
(2 i2 + 1)!
(%i5) args(expr)[1];
i2 2 i2 + 1
(- 1) x
(%o5) -----------------
(2 i2 + 1)!
If you want to change the index variable:
(%i6) niceindices(expr),niceindicespref=[n];
inf
==== n 2 n + 1
\ (- 1) x
(%o6) > ---------------
/ (2 n + 1)!
====
n = 0
newbie Maxima question
I have a transfer function in Maxima
E1 : y = K_i*s/(s^2 + w^2);
I'd like to have the closed-form of the equation affter applying the bilinear transform
E2 : s = (2/Ts*(z-1)/(z+1));
I would like to get the transfer function for z, by substituing s by equation E2. How should I proceed?
Regards
Note that subst can apply one or more substitutions stated as equations. In this case, try subst(E2, E1).
That will probably create a messy result -- you can simplify it somewhat by applying ratsimp to the result.
Here's what I get from that.
(%i2) E1 : y = K_i*s/(s^2 + w^2);
K_i s
(%o2) y = -------
2 2
w + s
(%i3) E2 : s = (2/Ts*(z-1)/(z+1));
2 (z - 1)
(%o3) s = ----------
Ts (z + 1)
(%i4) subst (E2, E1);
2 K_i (z - 1)
(%o4) y = ------------------------------
2
4 (z - 1) 2
Ts (z + 1) (------------ + w )
2 2
Ts (z + 1)
(%i5) ratsimp (%);
2
2 K_i Ts z - 2 K_i Ts
(%o5) y = -----------------------------------------------
2 2 2 2 2 2 2
(Ts w + 4) z + (2 Ts w - 8) z + Ts w + 4
I have an matrix in Maxima, let´s say (for simplification of the problem):
A: matrix([2*(a^2+b^2+c^2)])
But I know that:
a^2+b^2+c^2 = 1
How do I simplify that matrix in Maxima in terms of that equation, in order to obtain A = [2]?
I found the solution:
A: matrix([2*(a^2+b^2+c^2)]);
eq: a^2+b^2+c^2 = 1;
scsimp(A, eq);
You can use tellrat.
(%i1) A:matrix([2*(a^2+b^2+c^2)])
(%o1) [ 2 2 2 ]
[ 2 (c + b + a ) ]
(%i2) a^2+b^2+c^2 = 1
2 2 2
(%o2) c + b + a = 1
(%i3) solve(%,a^2)
2 2 2
(%o3) [a = (- c ) - b + 1]
(%i4) tellrat(%[1])
2 2 2
(%o4) [c + b + a - 1]
(%i5) algebraic:true
(%o5) true
(%i6) rat(A)
(%o6)/R/ [ 2 ]
(%i7) untellrat(a)
(%o7) []