Cramer's Rule - linear equations

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
vd.ashwini (373)
5/13/2008 6:50:18 AM
comp.soft-sys.matlab 207304 articles. 1 followers. lunamoonmoon (258) is leader. Post Follow

7 Replies
481 Views

Similar Articles

[PageSpeed] 54
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
mulgor (3009)
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
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
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
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
mulgor (3009)
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
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
vd.ashwini (373)
5/15/2008 5:41:02 AM
Reply:
Similar Artilces:

Trapzedial Rule
If you have two arrays, how can you set up a code to solve distance using trapezoidal rule? Do you have to set it as a function file? t = [1 2 3.25 4.5 6 7 8 8.5 9.3 10] v = [5 6 5.5 7 8.5 8 6 7 7 5] Thanks. Joba57 <basketball@aol.com> wrote in message <1363771665.59610.1291584284295.JavaMail.root@gallium.mathforum.org>... > If you have two arrays, how can you set up a code to solve distance using trapezoidal rule? Do you have to set it as a function file? > > t = [1 2 3.25 4.5 6 7 8 8.5 9.3 10] > v = [5 6 5.5 7 8.5 8 6 7 7 5] > > Thanks. *as...

Equation editor and matrices
I have the following puzzle with equations editor, which I am unable to solve: A sum of a square matrix (let say 3x3) and a column vector (3x1). The matrix has coefficients with pedixes and with divisions (a/b). The vector has simple coefficients. The result is that the height of the matrix is much higher as compared to the height of the vector. How can I allign matrix and vector to the same vertical size (i.e. to the same height)? I already tried without results: the positioning function which does not work with the square brackets, nor it seems towork "Matrix row he...

Can Matlab solve a system of equations contain one pde(1-D) equation and 3 ode equations by the pdepe solver?
I have a system of equations contains one one-dimensional pde and three ode. Can it be solved by the 'pdepe' solver? If it can,how do I treat the boundary function of odes? ...

How many scalar equations for 4-state Kalman filter
Hi, I read a paper it said that "For a 4-state Kalman filter, all the Kalman filter equations can be expressed as 30 scalar equations." Because 30 is not an integer multiples of 4, I do not know how it get 30 scalar equations. Could you help me on that? Thanks, On Fri, 01 Mar 2013 16:40:42 -0800, fl wrote: > Hi, > I read a paper it said that "For a 4-state Kalman filter, all the Kalman > filter equations can be expressed as 30 scalar equations." > > Because 30 is not an integer multiples of 4, I do not know how it get 30 > scalar equat...

Compound access rules?
First off: A disclaimer ... what I'm requesting is fairly complex and I don't really expect sendmail to be able to support it ... but I figure it can't hurt to ask. On to the question: Is there any way to setup a 'compound' rule in either the access table or a local_rule set? The problem is this ... I'm getting a lot of mail that is perporting to be from "support@mydomain.com" and "admin@mydomain.com". Obviously these are viruses/works trying to propigate themselves. What I would like to do is setup some rule that will reject mail if it matches ...

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 ...

METAL STRESS RELEASE RULE
In the tsmc18rf technology, slots must be placed for metals larger (at least one dimension) than 35 um. Does anyone know how these cuts are defined on the metal? I tried different layers but I cannot find one that defines an open slot. Does nayone have a clue? Thanks in advance. Mike On Sat, 21 Jan 2006 15:57:10 -0500, "michael_skoufis" <skouf1974@nospam.yahoo.com> wrote: >In the tsmc18rf technology, slots must be placed for metals larger (at >least one dimension) than 35 um. Does anyone know how these cuts are >defined on the metal? I tried different layers ...

NetFilter : connexion refused with my set of rules
Hello, I modified /etc/ssh/sshd_config to force ssh server to listen on port 443 : .... Port 443 .... So I try the connection from my machine like this : ssh -2 -p 443 theusername@themachinename From local, it works fine, but not from internet, because i don't know very well netfilter. I trace the connection try in /var/log/messages : ..... Sep 8 13:24:48 paradise kernel: IPTABLES TCP-IN: IN=eth1 OUT= MAC=00:60:4c:14:d8:2e:00:60:4c:14:d8:2f:08:00 SRC=145.248.192.4 DST=81.57.11.43 LEN=64 TOS=0x00 PREC=0x00 TTL=53 ID=42043 DF PROTO=TCP SPT=29333 DPT=443 WINDOW=32850...

pokern downloaden , play poker , geld online gewinnen , poker party , poker rules , geld verdienen mit umfragen , super mario online , fotos geld machen , echtgeld poker spielen , online poker
pokern downloaden , play poker , geld online gewinnen , poker party , poker rules , geld verdienen mit umfragen , super mario online , fotos geld machen , echtgeld poker spielen , online poker um geld spielen , * * * +++ GELD ONLINE VERDIENEN +++ GELD IM INTERNET VERDIENEN +++ * http://WWW.KOSTENLOS-SPIELEN.NL http://WWW.KOSTENLOS-SPIELEN.NL http://WWW.KOSTENLOS-SPIELEN.NL http://WWW.KOSTENLOS-SPIELEN.NL http://WWW.KOSTENLOS-SPIELEN.NL http://WWW.KOSTENLOS-SPIELEN.NL * * * romme spielen poker stadt einfach geld im internet verdienen wie kommt man schnell an viel geld internet viel geld ...

cramer using matlab
i am a new user for matlab i dont know how to solve this proplem in my HW: using cramers rule solve the following simultanous equations in 4 unkowns. Use matlab tp perform your calculations X2+X3+X4=1 X1+X3=1 X1+X2+X3+X4=1 X1+x4=1 HERE IS MY TRY: i wrote a function in M file ant that is it : function X=cramer[A,B] P=det(A); [n,n]=size(A) for j = 1 : n Q=A; Q(:,j) = B X(j)=det(Q)/P end X=X'; when i go tl command window and write A and B i got an error : >> A=[0 1 1 1; 1 0 1 0; 1 1 1 1; 1 0 0 1]; >> B=[1;1;1;1]; >> x=cramer(A,B) ??? Error: File: C:\MATLAB7...

[Fwd: Re: [Fwd: Rules of thumb (was:Re: HP : Massive strike and protest march today)] today)] today)]]
> BRAD wrote: > >>> I'm beginning to suspect that such claims about the "true" cost of >>> workers is rapidly approaching the status of "urban myth". Can anyone >>> clearly cite statistics that _prove_ otherwise? > > > Twice the base salary would include office costs. I think 40% to 50% is > about right. Of course, in companies with higher fringe benefits, those > costs would be higher. (for instance, consider Google that has valets > that handle chores on behalf of workers such as sending/fetching dry > cleaning...

Plucker rules / AvantGo blows...
The title says it all, really... My favourite features so far (I've only been using the program for 12 hours so far, but still it kicks ass compared to AvantGo I reckon...): 1) being able to use different fonts 2) the ability to store files on memory cards and thus free up valuable RAM 3) parsing files on your PC rather than on some remote server 4) the fact you can set the scrollbar to the left side (I'm a lefty!) Couple of issues though... I use a Clie NR70V with Plucker v1.4 and when I set the toolbar to the bottom, it floats somewhat ghostlike (semi-transparent) jus...

Rules for covariant returns???
Hi, Is there any documentation about the rules concerning the covariant return of a function? Can I return an abstract class? Can I return an interface? TIA Joost A variable defined as an interface or a class (whether abstract or not) can reference any object instantiated from that class, or a descendant thereof. Hashtable = new Properties();//no problem. Functions work exactly the same. Consider a method in the Collections class: List synchronizedList(List list) List is an interface. Any object might be returned, with the sole stipulation that it implements the LIst interface. Wa...

Solving for a Variable in an Equation
Hi, I have the following equation W = [(L/(S*M))^(SQRT(2(S+1))-1)]/(S*M - L) I want an equation for S in terms of W,L and M. Is there any way to get it? I appreciate your help on this. Thanks Paramesh ...

different font size for equations in Latex
Hi I am using 12p for the font for the whole article However I'd like to use some smaller font like 9pt for equations. Is there any ways for that? Thanks a lot! Helen wrote: > Hi I am using 12p for the font > for the whole article > However I'd like to use some smaller font like 9pt for equations. > Is there any ways for that? > Thanks a lot! I guess one could use \DeclareMathSizes{12}{9}{7}{5} (look at fntguide on your system). I don't quite know if this is enough -- /daleif (remove RTFSIGNATURE from email address) LaTeX FAQ: http://www.tex.ac.uk/faq...

solving a system of equations with a free variable
solve({x=ax+b},{a,b}); {b = x-ax, a = a} while I really meant "find x and y such that x=ax+b is identity for any x". The solution is obviously supposed to be {b = 0, a = 1} How would I tell this to Mapple? On 9 Apr 2004, Mikito Harakiri wrote: > solve({x=ax+b},{a,b}); > {b = x-ax, a = a} > > while I really meant "find x and y such that x=ax+b is identity for > any x". The solution is obviously supposed to be > > {b = 0, a = 1} > How would I tell this to Mapple? solve(identity(x = a*x+b, x), {a,b}); Hello! I do this ...

Re: [tao-bugs] TAO version overwrites SOVERSION and SONAME in rules.tao.GNU #2 #2
Hi Milan: I've prepared a patch to fix this and will check it in as soon as Bala gives me access to the repo. Here's my changelog entry. Please let me know how this works out for you... Mon Dec 8 19:44:04 UTC 2003 Don Hinton <dhinton@dresystems.com> .... Moved the initial assignment of SOVERSION and SONAME from wrapper_macros.GNU to rules.lib.GNU so that users can set them in a Makefile or in another file, e.g., rules.tao.GNU. Since it must be set prior to it's use in rules.lib.GNU--it's used in a target name that...

[News] [Rival] EU Ruling Mistakes Make Agreement Ineffective to Linux
Microsoft bows to EU ruling—will Linux now rise? ,----[ Quote ] | European businesses that have thus far shied away from Linux might not be | more inclined to go open source as a result of the restrictions imposed by | the commission. `---- http://www.eetasia.com/ART_8800486102_499495_NT_a1a889b9.HTM?click_from=RSS They should really play the unbundling card. People don't want Vista anyway. The Vole appears to be buying some more "IP". Microsoft to buy some assets of Bangkok developer ,----[ Quote ] | Microsoft, the Redmond, Wash., software giant, said it agreed to acqu...

Setting ICMP Rules
Can blocking all ICMP request by the FW cause problems on the TCP/IP connection? I have been having this issue with connecting to the ISP's news group server fro awhile. Where as, I get connection TCP/IP connection has been dropped by the server messages. After talking with the ISP Tech Support guru, he indicates that either the AV or FW is causing this issue. When it does happen, I cannot even ping netnews.insightbb.com or any other site. I get the timeouts and it will not clear until I reboot the machine. I can still surf the Internet and send pop3 email when this happens, but I cann...

Strange output from a logging rule
I'm running 8.13.8 on Solaris 9 and in an attempt to gather data on HELO arguments I have added some lines to log the HELO argument ($s) of every message: Klog syslog And in Local_check_mail: R$* $: $( log HELO=$&s $) $1 The goal being to have a NOP as far as the workspace was concerned but to log the runtime value of $s. It seems to basically work, except for the fact that when I manually do a SMTP session with 'HELO testhelostring' I get this: Aug 25 19:13:40 myhostname sm-mta[10061]: [ID 801593 mail.info] k7PNDTMA010061: HELO=.testhelostring Note the leading...

Apply rules to vectors
Hello, Is it possible given two vectors, A and B, create a third vector, C, using the following conditions, without a loop? D = A - B If D(i) * D(i-1) < 0 and D(i) > 0 then C(i) = 1 If D(i) * D(i-1) < 0 and D(i) < 0 then C(i) = -1 If D(i) * D(i-1) > 0 then C(i) = 0 --- If D(i) * D(i-1) = 0 then If D(i) * D(i-2) < 0 and D(i) > 0 then C(i) = 1 If D(i) * D(i-2) < 0 and D(i) < 0 then C(i) = -1 If D(i) * D(i-2) > 0 then C(i) = 0 end Basically I am creating a function that detects when a function crosses under or over an...

rules engines: faster implementation than methods invocations?
Hi, About rules engines (and jsr-94): We looked at 'drools', but it uses method invocations. ---> Is there other implementations around, not based on method invocation? Given that invocation is 50 to 300 times slower than compiled call, method invocation sucks big time at high throughputs. My only alternative is code generation at this point. Thanks. -------test code to show invocation cost------- package tests; import java.lang.reflect.Method; public class TestInvokeSpeed { static Method m_dovoid; static Method m_dolong; static Method m_dolongw; static { try ...

solving for 2 unknowns in an equation (or two) that involve complex numbers
I'm trying to solve for R and X in the equation: [59.0536R-60.369X-2682.0644+j*(60.369R+59.0536X-2759.334)]/[R +104.1269+j(X+60.2239)] = 17.4133+j2.6957 I'm wondering if there is any easy way to get the LHS to be expressed as a complex number in terms of R and X and then solve for R and X by matching real and imaginary components in Matlab. Thanks. In article <4273745a-a077-46f5-806c-72f6d4f481cf@e6g2000prf.googlegroups.com>, ssylee <stanigator@gmail.com> wrote: >I'm trying to solve for R and X in the equation: >[59.0536R-60.369X-2682.0644+j*(60.369R+59.0536X-2...

Re: [tao-bugs] TAO version overwrites SOVERSION and SONAME in rules.tao.GNU
Hi Milan: > Krishnakumar B wrote: > > On Tuesday, 2 December 2003, Milan Cvetkovic wrote: > >> Patch for rules.tao.GNU attached. > > > > > > This is broken. > > I am not sure what you mean by "this". > > > SOVERSION and SONAME were designed to track ACE & TAO's > > version numbers. And versioned_so was added later on to allow people to > > turn it off completely. They were not designed to be mucked around at will. > > And Ossama mentioned about some problems with the current naming and wanted &g...

Could someone else verify that an example from the Numerical Solutions to Differential Equations isn't working.
I am looking at the example on page 348 of the tutorial for a numerical solution to the Sine-Gordon equation. (http://www.wolfram.com/learningcenter/tutorialcollection/AdvancedNumericalDifferentialEquationSolvingInMathematica/). It doesn't work for me for M8.0.4, MacBook, MacOs 10.7.4. Can someone else verify that this doesn't work? Here is the example: L = 10; (*the tutorial has L=-10, but I think that is a typo. In any case, the example doesn't work with + or - *) state = First[NDSolve`ProcessEquations[{D[u[t, x, y], t, t] == D[u[t, x, y], x, x] + D[u[t, x, y],...