Items tagged with linear linear Tagged Items Feed

I have a set "EQ" containing N linear equations in N unknowns. The only symbolic variables in each "EQ[i]" are the unknowns. I want to write a procedure that derives the matrices "A" and "b" where A.x=b is the same linear system stored in "EQ". In other words, I want to write the linear system in the matrix form.

Can anyone guide me through writting such a procedure?
As an example do it with the system written in the following file.

Note: This procedure will be used for large linear systems (e.g. 2000 Equations, 2000 Unknowns) so it will be important that the procedure uses the least operations required.

LinearSystem.mw

Thanks in advance.

I have a large system of linear algebraic equations that I want to solve (2005 Unknowns, 2005 Equations). I was wondering that what are the proper commands to use in maple for solving the system as fast as possible. Take a look at the files in the download link if you want to see the system of linear algebraic equations.

http://pc.cd/h79

Please provide me any suggesitons that you may think will be helpful like using other sofwares that are good in doing this work such as MATLAB or something else.


Thanks in Advance




Hi there. 

I'm kind of new to Maple and i'm trying to solve a Linear Algebra problem for my class of Linear Algebra of the course of Physics. Also, my first language is portuguese so forgive for my not-so-perfect english.

I have a (solved) linear system of 7 equations and 12 variables (A, B, C, D, E, F, G, H, I, J, K, L) that is the following:

  • A = 33 - K - L
  • B = 1 + F - J
  • C = -15 - F + J + K + L
  • D = 15 + H - K
  • E = 16 - F - H + J + K
  • G = 34 - H - J - L
  • I = 18 - J - K

Note: I'm using letters (A, B, ..., L) instead of X1X2, ..., X12 because it's easier to write it like this here and because I don't know if the Xn notation is allowed on Maple (i don't think so).

So, the system is possible but undetermined (with 5 degrees of freedom), being F, H, J, K and L the free variables.

Until here, everything's fine. The problem arises when the professor asks us for every solution of the system that satisfies the condition that all the variables (form A to L) are positive integers (A, B, C, D, E, F, G, H, I, J, K, L ϵ IN → natural numbers).

From my understanding, that gives rise to a system of linear inequalities with 12 variables and the following inequalities:

  • A = 33 - K - L > 0
  • B = 1 + F - J > 0
  • C = -15 - F + J + K + L > 0
  • D = 15 + H - K > 0
  • E = 16 - F - H + J + K > 0
  • G = 34 - H - J - L > 0
  • I = 18 - J - K > 0
  • > 0
  • > 0
  • > 0
  • > 0
  • > 0                            (and A,B,C,D,E,F,G,H,I,J,K,L ϵ IN)



After some research, i found that a possible way to solve this type of system of linear inequalities is trough a method of elimination (analog to Gauss-Jordan's elimination method for systems of linear equations) named Fourier-Motzkin. But it's hardwork and i wanted to do it on the computer. After some research, i came across with the following Maple command:

SolveTools[Inequality][LinearMultivariateSystem]

http://www.maplesoft.com/support/help/Maple/view.aspx?path=SolveTools%2fInequality%2fLinearMultivariateSystem

So, I tried to use that command to solve my system, with the following result (or non-result):

with(SolveTools[Inequality]);
LinearMultivariateSystem({F > 0, H > 0, J > 0, K > 0, L > 0, 1+F-J > 0, 15+H-K > 0, 18-J-K > 0, 33-K-L > 0, 34-H-J-L > 0, -15-F+J+K+L > 0, 16-F-H+J+K > 0}, [F, H, J, K, L]);

Error, (in SolveTools:-Inequality:-Piecewise) piecewise takes at least 2 parameters


So, i really need help solving this as the professor told us that the first one to solve would win a book, eheh. I don't know what I'm doing wrong. Maybe this Maple command is not made for 12 variables? Or maybe i'm just writing something on a wrong form. I've never used Maple before so i can be doing something really stupid without knowing it.

I would really apreciate an answer, as my only goal as a future physicist is to unveil the secrets of the Cosmos to us all.

Thank you again.

Miguel Jesus





Dear Maple enthusiasts,

I am unable to find a working method to solve a system of 8 equations, of which 4 are differential equations. The system contains 8 unknown variables and the goal is to find an expression for each of these variables as a function of the time t. I have attached the code of my project at the bottom of this message.

I have tried the following:

  1. Using solve/dsolve to solve all 8 equations at once. This results in Maple eating up all of my memory and never finishing its calculations.
  2. First using solve to solve the 4 non-differential equations so that I get 4 out of 8 variables as a function of the 4 remaining variables. This results in an expression containing RootOf() for each of the 4 veriables I'm solving for, which prevents me from using these expressions in the 4 remaining differential equations.
  3. First using dsolve to solve the differential equations, which gives once again an expression for 4 variables as a function of the 4 remaining variables. I then use solve to solve the 4 remaining equations with the new found expressions. This results in an extremely long solution for each of the variables.

The code below contains the 3rd option I tried.

Any help or suggestions would be greatly appreciated. I have been scratching my head so much that I'm getting bald and whatever I search for on google or in the Maple help, I can't find a good reference to a system of differential equations together with other equations.

 

 

restart:

PARK - Mixed control

 

 

Input parameters

 

 

Projected interface area (m²)

A_int:=0.025^2*Pi:

 

Temperature of the process (K)

T_proc:=1873:

 

Densities (kg/m³)

Rho_m:=7000: metal

Rho_s:=2850: slag

 

Masses (kg)

W_m:=0.5: metal

W_s:=0.075: slag

 

Mass transfer coefficients (m/s)

m_Al:=3*10^(-4):

m_Si:=3*10^(-4):

m_SiO2:=3*10^(-5):

m_Al2O3:=3*10^(-5):

 

Weight percentages in bulk at t=0 (%)

Pct_Al_b0:=0.3:

Pct_Si_b0:=0:

Pct_SiO2_b0:=5:

Pct_Al2O3_b0:=50:

 

Weight percentages in bulk at equilibrium (%)

Pct_Al_beq:=0.132:

Pct_Si_beq:=0.131:

Pct_SiO2_beq:=3.13:

Pct_Al2O3_beq:=52.12:

 

Weight percentages at the interface (%)

Constants

 

 

Atomic weights (g/mol)

AW_Al:=26.9815385:

AW_Si:=28.085:

AW_O:=15.999:

AW_Mg:=24.305:

AW_Ca:=40.078:

 

Molecular weights (g/mol)

MW_SiO2:=AW_Si+2*AW_O:

MW_Al2O3:=2*AW_Al+3*AW_O:

MW_MgO:=AW_Mg+AW_O:

MW_CaO:=AW_Ca+AW_O:

 

Gas constant (m³*Pa/[K*mol])

R_cst:=8.3144621:

 

Variables

 

 

with(PDEtools):
declare((Pct_Al_b(t),Pct_Al_i(t),Pct_Si_b(t),Pct_Si_i(t),Pct_SiO2_b(t),Pct_SiO2_i(t),Pct_Al2O3_b(t),Pct_Al2O3_i(t))(t),prime=t):

Equations

 

4 rate equations

 

 

Rate_eq1:=diff(Pct_Al_b(t),t)=-A_int*Rho_m*m_Al/W_m*(Pct_Al_b(t)-Pct_Al_i(t));

 

Rate_eq2:=diff(Pct_Si_b(t),t)=-A_int*Rho_m*m_Si/W_m*(Pct_Si_b(t)-Pct_Si_i(t));

 

Rate_eq3:=diff(Pct_SiO2_b(t),t)=-A_int*Rho_s*m_SiO2/W_s*(Pct_SiO2_b(t)-Pct_SiO2_i(t));

 

Rate_eq4:=diff(Pct_Al2O3_b(t),t)=-A_int*Rho_s*m_Al2O3/W_s*(Pct_Al2O3_b(t)-Pct_Al2O3_i(t));

 

3 mass balance equations

 

 

Mass_eq1:=0=(Pct_Al_b(t)-Pct_Al_i(t))+4*AW_Al/(3*AW_Si)*(Pct_Si_b(t)-Pct_Si_i(t));

 

Mass_eq2:=0=(Pct_Al_b(t)-Pct_Al_i(t))+4*Rho_s*m_SiO2*W_m*AW_Al/(3*Rho_m*m_Al*W_s*MW_SiO2)*(Pct_SiO2_b(t)-Pct_SiO2_i(t));

 

Mass_eq3:=0=(Pct_Al_b(t)-Pct_Al_i(t))+2*Rho_s*m_Al2O3*W_m*AW_Al/(Rho_m*m_Al*W_s*MW_Al2O3)*(Pct_Al2O3_b(t)-Pct_Al2O3_i(t));

 

1 local equilibrium equation

 

 

Gibbs free energy of the reaction when all of the reactants and products are in their standard states (J/mol). Al and Si activities are in 1 wt pct standard state in liquid Fe. SiO2 and Al2O3 activities are in respect to pure solid state.

 

delta_G0:=-720680+133*T_proc:

 

Expression of mole fractions as a function of weight percentages (whereby MgO is not taken into account, but instead replaced by CaO ?)

x_Al2O3_i(t):=(Pct_Al2O3_i(t)/MW_Al2O3)/(Pct_Al2O3_i(t)/MW_Al2O3 + Pct_SiO2_i(t)/MW_SiO2 + (100-Pct_SiO2_i(t)-Pct_Al2O3_i(t))/MW_CaO);
x_SiO2_i(t):=(Pct_SiO2_i(t)/MW_SiO2)/(Pct_Al2O3_i(t)/MW_Al2O3 + Pct_SiO2_i(t)/MW_SiO2 + (100-Pct_SiO2_i(t)-Pct_Al2O3_i(t))/MW_CaO);

 

Activity coefficients

Gamma_Al_Hry:=1: because very low percentage present  during the process (~Henry's law)

Gamma_Si_Hry:=1: because very low percentage present  during the process (~Henry's law)

Gamma_Al2O3_Ra:=1: temporary value!

Gamma_SiO2_Ra:=10^(-4.85279678314968+0.457486603678622*Pct_SiO2_b(t)); very small activity coefficient?
plot(10^(-4.85279678314968+0.457486603678622*Pct_SiO2_b),Pct_SiO2_b=3..7);

 

Activities of components

a_Al_Hry:=Gamma_Al_Hry*Pct_Al_i(t);
a_Si_Hry:=Gamma_Si_Hry*Pct_Si_i(t);
a_Al2O3_Ra:=Gamma_Al2O3_Ra*x_Al2O3_i(t);
a_SiO2_Ra:=Gamma_SiO2_Ra*x_SiO2_i(t);

 

Expressions for the equilibrium constant K

K_cst:=exp(-delta_G0/(R_cst*T_proc));

Equil_eq:=0=K_cst*a_Al_Hry^4*a_SiO2_Ra^3-a_Si_Hry^3*a_Al2O3_Ra^2;

 

Output

 

 

with(ListTools):
dsys:=Rate_eq1,Rate_eq2,Rate_eq3,Rate_eq4:
dvars:={Pct_Al2O3_b(t),Pct_SiO2_b(t),Pct_Al_b(t),Pct_Si_b(t)}:
dconds:=Pct_Al2O3_b(0)=Pct_Al2O3_b0,Pct_SiO2_b(0)=Pct_SiO2_b0,Pct_Si_b(0)=Pct_Si_b0,Pct_Al_b(0)=Pct_Al_b0:
dsol:=dsolve({dsys,dconds},dvars):

Pct_Al2O3_b(t):=rhs(select(has,dsol,Pct_Al2O3_b)[1]);
Pct_Al_b(t):=rhs(select(has,dsol,Pct_Al_b)[1]);
Pct_SiO2_b(t):=rhs(select(has,dsol,Pct_SiO2_b)[1]);
Pct_Si_b(t):=rhs(select(has,dsol,Pct_Si_b)[1]);

sys:={Equil_eq,Mass_eq1,Mass_eq2,Mass_eq3}:
vars:={Pct_Al2O3_i(t),Pct_SiO2_i(t),Pct_Al_i(t),Pct_Si_i(t)}:
sol:=solve(sys,vars);

,


Download Park_-_mixed_control_model.mw

Dear Maple experts,

 

I would like to visualize the equation -3*x+2*y+3*z=0  and (with other color) 2*y+3*z =0. I used the following commands:

with(Student[LinearAlgebra]):
infolevel[Student[LinearAlgebra]]:=1:
PlanePlot(-3*x+ 2*y + 3*z = 0, [x,y,z], normaloptions=[shape=harpoon], showbasis);

But I do not know how to show at the same time the second equation (2*y+3*z=0 ).

 

How should I proceed? Any hint?

Thanks for your attention,

 

Jean-Jaques

 

A linear system with three variables has augmented matrix that is row-equivalent to the 
following matrix: 

k + 3 2 k − 4 = 3 
0 2 −9 = 5 
0 0 k^2 + k − 2 = k − 1 
Determine the values of k for which the system has: 
(a) exactly one solution, 
(b) infinitely many solutions, 
(c) no solutions.

I have a matrix with repeated columns

with(LinearAlgebra):

Q := Matrix([1,1,1,0,0,0,-2,-1],[0,0,0,1,1,1,0,-3]);

I'd like to write a loop that defines u[1],...,u[n] to be the unique columns of Q. Is there a way to do this?

hi all.

I have wrore the following program for optimization with bernstein and block pulse hybrid functions.

the program have some errors which i can't understand.

Bernestien1.mws

restart:

alias(C=binomial):
with(LinearAlgebra):
macro(LA= LinearAlgebra):


HybrFunc:=proc(N, M,  tj)               # N=Number of subintervals,  M=Number of functions in subintervals
 
local B, n, m;

global b;

for n from 1 to N do
for m from 0 to M-1 do

B := (i,m,t) -> C(m,i)*(1-t)^(m-i)*t^i:

b[n,m]:=unapply(piecewise(t>=(n-1)*tj/N and t<n*tj/N, B(m,2,N*t-(n-1)*tj), 0), t):
 od:od:


Array(1..N, 0..M-1, (n,m)->b[n,m](t)):

#convert(%,vector);
end proc:

HybrFunc(3, 3, 1);




                                       # End Of Definition
 
g2(t):=t;            #*exp(t-1):                      # Any other function can be replaced here
    

g1(t):=add(add(c[n,m]*b[n,m](t), m=0..2), n=1..3);
Optimization[Minimize](sqrt(int((g2(t)-g1(t))^2, t=0.. 1)));
assign(op(%[2]));
plot([g2(t),g1(t)], t=0..1, 0..5, color=[blue,red],thickness=[1,3],discont, scaling=constrained);

Array(1 .. 3, 0 .. 2, {(1, 0) = piecewise(0 <= t and t < 1/3, (1-3*t)^2, 0), (1, 1) = piecewise(0 <= t and t < 1/3, (6*(1-3*t))*t, 0), (1, 2) = piecewise(0 <= t and t < 1/3, 9*t^2, 0), (2, 0) = piecewise(1/3 <= t and t < 2/3, (2-3*t)^2, 0), (2, 1) = piecewise(1/3 <= t and t < 2/3, (2*(2-3*t))*(3*t-1), 0), (2, 2) = piecewise(1/3 <= t and t < 2/3, (3*t-1)^2, 0), (3, 0) = piecewise(2/3 <= t and t < 1, (3-3*t)^2, 0), (3, 1) = piecewise(2/3 <= t and t < 1, (2*(3-3*t))*(3*t-2), 0), (3, 2) = piecewise(2/3 <= t and t < 1, (3*t-2)^2, 0)}, datatype = anything, storage = rectangular, order = Fortran_order)

g2(t) := t

"g1(t):=c[1,0] ({[[(1-3 t)^2,0<=t and t<1/3],[0,otherwise]])+c[1,1] ({[[6 (1-3 t) t,0<=t and t<1/3],[0,otherwise]])+c[1,2] ({[[9 t^2,0<=t and t<1/3],[0,otherwise]])+c[2,0] ({[[(2-3 t)^2,1/3<=t and t<2/3],[0,otherwise]])+c[2,1] ({[[2 (2-3 t) (3 t-1),1/3<=t and t<2/3],[0,otherwise]])+c[2,2] ({[[(3 t-1)^2,1/3<=t and t<2/3],[0,otherwise]])+c[3,0] ({[[(3-3 t)^2,2/3<=t and t<1],[0,otherwise]])+c[3,1] ({[[2 (3-3 t) (3 t-2),2/3<=t and t<1],[0,otherwise]])+c[3,2] ({[[(3 t-2)^2,2/3<=t and t<1],[0,otherwise]])"

Error, (in Optimization:-NLPSolve) complex value encountered

Error, invalid left hand side in assignment

(1)



Download Bernestien1.mws

 I'll be so grateful if any one can help me.

Mahmood   Dadkhah

Ph.D Candidate

Applied Mathematics Department

 http://en.wikibooks.org/wiki/Linear_Algebra/

Representing_Linear_Maps_with_Matrices

 

how to calculate the first step

(2,0) -> (1,1,1) and (1,4) -> (1,2,0)

how to use maple command to get (1,1,1) and (1,2,0)

how to use maple command to calculate rep(h)

 

to get (0,-1/2,1) and (1,-1,0)

http://en.wikibooks.org/wiki/Linear_Algebra

/Representing_Linear_Maps_with_Matrices

I'm having some trouble maybe someone can point out my error please. I'm using the Maple 18 worksheet to try some basic linear equations. The trouble is in the last step.

 

1.) I start with 2 ordered pairs (2, 14) and (14,18)

Then I put in my formula to discover the slope. I confirm it looks correct in the Variables window.

m := (y2-y1)/(x2-x1);

 

2.)  Next I input the values for my ordered pairs. I also confirm thru the Variables window.

x1 := 2;

y1 := 14;

x2 := 3;

y2 := 18;

 

3.) Now I can type m and expect to get an answer to what my slope is.

m;

4.) Now I want Slope/Intercept form of y=mx+b. When I put in the formula y-y1=m(x-x1) i get a strange result

 

When I execute this formula, the result is y-14=4. (or thru context menu I tell it to solve for y, then I get y=18)

y-y1=m(x-x1) 

When I manually input the values, the output is y-14=4x-8 (or thru context menu I tell it to solve for y, then I get y=4x+6)

y-14 = 4*(x-2)

 

 

 

Why is my equation (y-y1=m(x-x1)) not executing properly?

Hi,

I have a linear system to solve.

 

mm:=proc(a,x,h,i)
local A,Z1,Z2,Z,F,result;  # to declare the local variable
A:=array(1..2,1..2,[[1,1],[a,a+h]]);
Z1:=evalf(int(1/(abs(y-x)+.000000001),y=a..a+h));
Z2:=evalf(int(y/(abs(y-x)+.000000001),y=a..a+h));
Z:=array([Z1,Z2]);
F:=evalm(inverse(A)&*Z);
result:=F[i]
end:

My questions: 

1) My exact Z1 is Z1:=evalf(int(1/(abs(y-x)),y=a..a+h)); but I ask if can I put

Z1:=evalf(int(1/(abs(y-x)+.000000001),y=a..a+h));

the same for Z2.

2) Can I writte in a simple form the vector Z.  Because, later, il have a second system contains Z1,Z2, Z3, Z4,Z5.  The difference between Z1 and Z2 is the variable "y" added in the integral of Z2.

 

Many thinks.

 

Hi,

I have these lines in my code, the function alpha:=(m,n,1)->...... is defined in the last line of the code below, but when I want to calculate alpah(1,1,1), there is no numeric value. Why????  Many thinks

 

 restart:
with(LinearAlgebra):
with(plots):
with(PDEtools):
with(IntegrationTools):
interface(rtablesize=20):
d:=1: N:=2: a:=1: h:=a/N:
Kernel(x,y):=ln(abs(x-y)):

 eq2:=int(Kernel(x,y)*phi(y),y=-a..a)=sum(int(Kernel(x,y)*phi(y),y=n*h..(n+d)*h),n=-N..N-d):

Approximate the integral
eq3:=phi->int(Kernel(x,y)*phi(y),y=n*h..(n+d)*h)=add(beta[i,n]*phi((n+i-1)*h),i=1..d+1):
eq4:=int(Kernel(x,y)*phi(y),y=n*h..(n+d)*h)=add(alpha[m,n,i]*phi((n+i-1)*h),i=1..d+1):

Compute the coefficients  beta[i]

Vct_basis:=[seq(x^i,i=0..d+1)]:
fct:=[seq(unapply(Vct_basis[i],x),i=1..d+2)]:


sys:=[seq(eq3(fct[i]),i=1..d+1)]:
x:=m*h:
w := [seq(beta[i,n],i=1..d+1)]:
M,b := GenerateMatrix(sys,w):

M1:=-M: V:=-b:

Vect_beta:=(M1)^(-1).V:# Vect_beta is a vector.

beta[1]:=Vect_beta[1]:  
alpha1:=(n,m)->beta[1];
(n, m) -> beta[1]
alpaha(1,1);
                                alpaha(1, 1)  ??????????????????? No numeric result


1 2 3 4 5 6 7 Last Page 1 of 24