COMPGROUPS.NET | Browse | Post | Groups | Users | Stream | About | |

### Cramer's Rule - linear equations

• Email
• Follow

I have three linear equations with 3 unknowns, say for example:

3x + 4y + 6z = 1;
x - 2y + 7z = 10;
2x + 3y - 9z = 15;

How do i solve this using matlab, is there any easiest way
to apply Cramer's Rule to Solve these equations ???

Any help would be appreciated !!
Thanks !
Ashwini


 0
Reply vd.ashwini (373) 5/13/2008 6:50:18 AM

See related articles to this posting

On May 13, 6:50=A0pm, "Ashwini Deshpande" <vd.ashw...@mathworks.com>
wrote:
> I have three linear equations with 3 unknowns, say for example:
>
> 3x + 4y + 6z =3D 1;
> x - 2y + 7z =3D 10;
> 2x + 3y - 9z =3D 15;
>
> How do i solve this using matlab, is there any easiest way
> to apply Cramer's Rule to Solve these equations ???
>
> Any help would be appreciated !!
> Thanks !
> Ashwini

If you're using Matlab, why would you even contemplate using Cramer's
Rule?
You would only use that if you wanted to solve it by hand - or you
needed to do it for homework.

If you genuinely want to solve the equations in Matlab, try: help
mldivide


 0
Reply mulgor (3012) 5/13/2008 8:06:33 AM

"Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in
message <g0bdna$rjm$1@fred.mathworks.com>...
> I have three linear equations with 3 unknowns, say for
example:
>
> 3x + 4y + 6z = 1;
> x - 2y + 7z = 10;
> 2x + 3y - 9z = 15;
>
> How do i solve this using matlab, is there any easiest way
> to apply Cramer's Rule to Solve these equations ???
>
> Any help would be appreciated !!
> Thanks !
> Ashwini
>

Cramer's Rule:  It may be slow, but it's inaccurate!

James Tursa


 0
Reply aclassyguywithaknotac (1113) 5/13/2008 8:26:04 AM

NZTideMan wrote:
> On May 13, 6:50 pm, "Ashwini Deshpande" <vd.ashw...@mathworks.com>
> wrote:
>> I have three linear equations with 3 unknowns, say for example:
>>
>> 3x + 4y + 6z = 1;
>> x - 2y + 7z = 10;
>> 2x + 3y - 9z = 15;
>>
>> How do i solve this using matlab, is there any easiest way
>> to apply Cramer's Rule to Solve these equations ???
>>
>> Any help would be appreciated !!
>> Thanks !
>> Ashwini
>
> If you're using Matlab, why would you even contemplate using Cramer's
> Rule?
> You would only use that if you wanted to solve it by hand - or you
> needed to do it for homework.
>
> If you genuinely want to solve the equations in Matlab, try: help
> mldivide

Perhaps the OP meant "Is there any easier way than to apply Cramer's Rule?"

 0
Reply dbell5608 (63) 5/14/2008 12:00:33 AM

"Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in message
<g0bdna$rjm$1@fred.mathworks.com>...
> I have three linear equations with 3 unknowns, say for example:
>
> 3x + 4y + 6z = 1;
> x - 2y + 7z = 10;
> 2x + 3y - 9z = 15;
>
> How do i solve this using matlab, is there any easiest way
> to apply Cramer's Rule to Solve these equations ???
>
> Any help would be appreciated !!
> Thanks !
> Ashwini
-------------
It is true that using Cramer's Rule in matlab would in general constitute an
inefficient method of solving linear equations, when there are so many
superior algorithms available.  However, it must be said in defense of
Cramer's Rule that it remains a very useful tool in mathematics, both in
understanding the theory in linear algebra and also for doing certain symbolic
manipulations.  I personally have to resort to its use quite often in deriving
various formulas and the like.  It is only in the area of actual numerical
computation that other methods become preferable.

Roger Stafford


 0
Reply ellieandrogerxyzzy (4806) 5/14/2008 12:54:01 AM

On May 14, 12:54=A0pm, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> "Ashwini Deshpande" <vd.ashw...@mathworks.com> wrote in message
>
> <g0bdna$rj...@fred.mathworks.com>...> I have three linear equations with 3= unknowns, say for example: > > > 3x + 4y + 6z =3D 1; > > x - 2y + 7z =3D 10; > > 2x + 3y - 9z =3D 15; > > > How do i solve this using matlab, is there any easiest way > > to apply Cramer's Rule to Solve these equations ??? > > > Any help would be appreciated !! > > Thanks ! > > Ashwini > > ------------- > =A0 It is true that using Cramer's Rule in matlab would in general constit= ute an > inefficient method of solving linear equations, when there are so many > superior algorithms available. =A0However, it must be said in defense of > Cramer's Rule that it remains a very useful tool in mathematics, both in > understanding the theory in linear algebra and also for doing certain symb= olic > manipulations. =A0I personally have to resort to its use quite often in de= riving > various formulas and the like. =A0It is only in the area of actual numeric= al > computation that other methods become preferable. > > Roger Stafford I agree entirely with you Roger, but the OP quoted a numerical example, not a symbolic one. How large a matrix would you use Cramer's Rule on? Back when I learnt it and access to computers was difficult (i.e., Hollerith cards submitted as a background job) I could handle 3x3 no trouble and 4x4 with a bit of effort, but these days 2x2 would be my limit before finding a better way.   0 Reply mulgor (3012) 5/14/2008 7:21:45 AM "Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in message <g0bdna$rjm$1@fred.mathworks.com>... > I have three linear equations with 3 unknowns, say for example: > > 3x + 4y + 6z = 1; > x - 2y + 7z = 10; > 2x + 3y - 9z = 15; > > How do i solve this using matlab, is there any easiest way > to apply Cramer's Rule to Solve these equations ??? > > Any help would be appreciated !! > Thanks ! > Ashwini > If you want to learn why Cramer's Rule is not a very good method numerically and why it is avoided, particularly for large problems, consider the code below and try it for inputs of 100, 200, 300, 400, 500, 600. The intermediate numbers get huge (eventually blows up), the timings get very long, and it is not as accurate as the built in MATLAB \ operator. Like I said, it's slow, but it's inaccurate. James Tursa ------------------------------ function callcramer(m) disp(' '); A = rand(m,m); b = rand(m,1); disp('Timing backslash:'); tic x = A\b; % Backslash operator for solving A*x = b toc xc = cramersrule(A,b); disp(['norm of backslash residual = ' num2str(norm(A*x-b),4)]); disp(['norm of Cramer''s Rule residual = ' num2str(norm(A*xc-b),4)]); disp(' '); return end function x = cramersrule(A,b) % Demo of Cramer's Rule for solving A*x = b disp('Timing Cramer''s Rule:'); tic [m n] = size(b); z = zeros(m,1); Ai = A; for k=1:m Ai(:,k) = b; z(k) = det(Ai); Ai(:,k) = A(:,k); end detA = det(A); x = z / detA; toc disp(['Max abs(det(Ai)) = ' num2str(max(abs(z)),4)]); disp(['abs(det(A)) = ' num2str(abs(detA),4)]); return end   0 Reply aclassyguywithaknotac (1113) 5/14/2008 7:53:01 AM "James Tursa" <aclassyguywithaknotac@hotmail.com> wrote in message <g0e5ot$96$1@fred.mathworks.com>... > "Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in > message <g0bdna$rjm$1@fred.mathworks.com>... > > I have three linear equations with 3 unknowns, say for > example: > > > > 3x + 4y + 6z = 1; > > x - 2y + 7z = 10; > > 2x + 3y - 9z = 15; > > > > How do i solve this using matlab, is there any easiest way > > to apply Cramer's Rule to Solve these equations ??? > > > > Any help would be appreciated !! > > Thanks ! > > Ashwini > > > > If you want to learn why Cramer's Rule is not a very good > method numerically and why it is avoided, particularly for > large problems, consider the code below and try it for > inputs of 100, 200, 300, 400, 500, 600. The intermediate > numbers get huge (eventually blows up), the timings get very > long, and it is not as accurate as the built in MATLAB \ > operator. Like I said, it's slow, but it's inaccurate. > > James Tursa > > ------------------------------ > > function callcramer(m) > disp(' '); > A = rand(m,m); > b = rand(m,1); > disp('Timing backslash:'); > tic > x = A\b; % Backslash operator for solving A*x = b > toc > xc = cramersrule(A,b); > disp(['norm of backslash residual = ' > num2str(norm(A*x-b),4)]); > disp(['norm of Cramer''s Rule residual = ' > num2str(norm(A*xc-b),4)]); > disp(' '); > return > end > > function x = cramersrule(A,b) % Demo of Cramer's Rule for > solving A*x = b > disp('Timing Cramer''s Rule:'); > tic > [m n] = size(b); > z = zeros(m,1); > Ai = A; > for k=1:m > Ai(:,k) = b; > z(k) = det(Ai); > Ai(:,k) = A(:,k); > end > detA = det(A); > x = z / detA; > toc > disp(['Max abs(det(Ai)) = ' num2str(max(abs(z)),4)]); > disp(['abs(det(A)) = ' num2str(abs(detA),4)]); > return > end > Thanks one and all ... I solved my problem .. All the replies were useful... Ashwini   0 Reply vd.ashwini (373) 5/15/2008 5:41:02 AM 7 Replies 152 Views Similar Articles [PageSpeed] 7 • Permalink • Email • Follow  Reply: Similar Artilces: CRAMERS Rule? Given the following two-equations-two unknowns, write a computer program, using CRAMERS&#8217;RULE to solve for the roots. aX + bY = C dX + eY = f DATA: a b c d e f 2 5 -1 2 5 -5 0 3 8 -.5 3 2 -2 -3 0 -.3 0 4 Cramer's rule is used in solving linear system of equations. Just follow up this : http://en.wikipedia.org/wiki/Cramer%27s_rule ... function using cramers rule Hello, I have spent several hours trying to write a function using cramer's rule. Unfortunatly, I can't use any short cuts or built in functions matlab already has. It has to be a three by three matrix with inputs A and B and out puts X1,X2,and X3. Does anyone have any samples I could study or suggestions for me?? Thanks for any help, I'm not looking to copy anyones work I want to learn how to do it, just needs some guidance or direction to go in Thanks. Steve Dunn steve wrote: > > > Hello, > > I have spent several hours trying to write a function using > crame... Transform differential equation by tranformation rule Dear Mathematica users, I want to transform one different equation (variable r,z) to another different equation (variable x,y). The origin equation is : equation = Derivative[0, 2][u][r, z] + Derivative[1, 0][u][r, z]/r + Derivative[2, 0][u][r, z] == 0 The transform rule is : r = Cos[x]Sinh[y] z = Sin[x] Cosh[y] ============ Now, my task is simple, apply this transform to differential equation. I do like this : transformRule = {r[x][y]-> Cos[x]Sinh[y], z[x][y]-> Sin[x] Cosh[y]} dtrules=Join @@ ({#,D[#,t],D[#,{t,2}]} & /@ transformRule) But it seems that... Vectorize Cramer's Rule Hi: I know that the Cramer's rule is quite trivial and discussed here before. But I was looking for a solution for the general nxn case without using any kind of loops,for,if, while commands. Just using basic Matlab commands. I appreciate any elegant or vectorized solutions. "Barry yenafar" <yeknafar@yahoo.com> wrote in message news:eeeb6af.-1@webx.raydaftYaTP... > Hi: > > I know that the Cramer's rule is quite trivial and discussed here > before. But I was looking for a solution for the general nxn case > without using any kind of loops,for,if, while c... Use of Mathematica with Rule-based Equation Derivations Hi All - I'm a many-year user of mathematica, but have always had one particular problem with it that I may have just simply missed reading about. Mathematica Version: 5.2 Problem: I would like to develop a set of re-rewite rules to apply to the Expected Value operator. For example: E[a x] = a E[x] a -> constant, x -> variable E[b + f[x]] = b + E[f[x]] , etc. The issue is how does one using Mathematica distinguish a 'constant variable (i.e. a and b)' from a variable 'variable' (i.e. 'x')? The head of a, b and x is 'Symbol' and neith... Re: Use of Mathematica with Rule-based Equation Derivations Hi, set up a global list of your constants and check the symbol if it is a member of that list. Regards Jens <mmorriss@gcn.ou.edu> schrieb im Newsbeitrag news:dkfd8o$etv$1@smc.vnet.net... | Hi All - I'm a many-year user of mathematica, but have always had one | particular problem with it that I may have just simply missed reading | about. | | Mathematica Version: 5.2 | | Problem: I would like to develop a set of re-rewite rules to apply to the | Expected Value operator. For example: | | E[a x] = a E[x] a -> constant, x -> variable | E[b + f[x]]... rule to skip other rules With bat-book in lap, I've been trying to figure this out, but no luck so far. I wrote this little snippet to reject all envelope recipients that don't begin with 'foo' or 'bar'. This works great on sendmail 8.11, but on 8.12.x, with local MTA bound to 127.0.0.1, messages destined to local user "root", "postmaster", etc., are getting rejected. What's the best way to say skip my ruleset below based on the sending host (localhost)? I'm familiar with rejecting mail based on certain conditions, but not accepting it. FYI: I tried stuff like &quo... Fuzzy rules reduction (49 rules to 7 rules) Hello, everybody. (Please, excuse my bad english...) Ok. I am working in a small software with Ada95 (on Linux) and a PCL_812 card, to control an electric oven. I can see in some papers and other documents the following info: If I have (for a fuzzy controller with two inputs) 49 rules on this way: e(k) NB NB NS ZE PS PM PB NB NB NB NB NB NM NS ZE NM NB NB NM NM NS ZE PS NS NB NM NS NS ZE PS PM de(k) ZE NM NM NS ZE PS PM PM PS NM NS ZE PS PS PM PB PM NS ZE PS PM PM PB PB PB ZE PS PM PB PB PB... Equation numbers only on referenced equations Hello, When I typeset a document with equations, I like that only those equations that are referenced somewher in the text are numbered. Is there any way to do that automagically, from the \ref{} tags found, instead of having to manually change equation for equation*? I've searched the web extensively, but haven't found any clue. Thanks in advance, V=EDctor V�ctor Zabalza wrote: > Hello, > > When I typeset a document with equations, I like that only those > equations that are referenced somewher in the text are numbered. Is > there any way to do that automagically... use equations out of list of equations Hello, I have solved a system of equations in MuPAD with linsolve, and as result I get a list of equations e.g. [a = c/2 + d/2, b = - c/2 - d/2]. I am able to index the list and get the single entries (equations) e.g. a = c/2 + d/2 but I cannot use them for my next calculation steps. Is there a way to get only the right hand side of these equations, that I can use them for further calculations? Thank you for your help. "Marcus " <lrt49861@stud.uni-stuttgart.de> wrote in message <hdtilc$inf\$1@fred.mathworks.com>... > Hello, > > I have solved a system of equa...