COMPGROUPS.NET | Post | Groups | Users | Stream | Browse | 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 (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
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 (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 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  comp.soft-sys.matlab 206679 articles. 558 followers. 7 Replies 462 Views Similar Articles [PageSpeed] 35 • 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 ... 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... 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... 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... 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$etv1@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]]... Cramer's rule using LinearAlgebra package? Using the older linalg package, I could implement Cramer's rule, given a matrix A and vector by (for example): > A1:=copyinto(b,copy(A),1,1); > det(A1)/det(A); But I can't work out how to do something similar with the newer LinearAlgebra package. For example: > A1:=A; > A1[1..4,1]:=b; (for a 4x4 system). But this changes both A1 and A, so that > Determinant(A1)/Determinant(A); produces 1. If I assign A1:=copy(A) the same thing happens. Clearly I want to write the vector b into a column of a copy of A, without changing the original matrix A. S... equation numbering for multipart equation How can I get separate equation numbering for equations like in "cases" environment? For example: $$f(x)=\begin{cases} \frac{1}{2} \\ x^2 \\ 1 \end{cases}$$ should look like 1/2 (1.1) f(x) = { x^2 (1.2) 1 (1.3) The lines in my real problem are quite complicated and have different heights. Further, I would like to be able to refer to the labels, and the labels should align at the right margin of the text, just like with usual equation numbers. Any help appreciated!... 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... Scaling equations/Spacing in equations Hello, I have two different problems with equations in latex. First I would like to scale some of my equations. Everything I tried, caused the numbering to be scaled. I found no way to suppress the scaling of numbering. (I tried to set the size by the fontsize command and with a scalebox). How can I scale my equation without scaling the numbering? The second problem is the space between the variables. Currently I'm using \; to define spacing between two variables. Does someone know a good solution to solve this problem without using a spacing command by a global setting or special rules t... 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 <hdtilcinf$1@fred.mathworks.com>... > Hello, > > I have solved a system of equa... Excel equation to Access Equation Is the any way to convert an equation in Excel to something Access will understand other than manually rewriting the code? Basic equation has several *MOD(A,B) and several IF(AND(C,D)... simply changing MOD(A,B) to (A MOB B) and changing IF(AND(C,D)... to IIF(C AND D)... does not do the trick. I suspect I'm having parentheses problems. A, B, C, and D are themselves complex equations. Chuck On Thu, 07 Jun 2007 13:56:16 -0400, Chuck <libbeyc@schoollink.net> wrote: No, you're on your own. -Tom. >Is the any way to convert an equation in Excel to something Access will >un... Very simple number equation does not equate. Dear matlab gurus, I encountered a very puzzling problem. 0.2+0.2+0.2+0.15+0.05 clearly adds up to 0.8. But on matlab R2007b, it does not equate. Why? I have been tearing my hair apart as this problem looks so simple and yet elusive. Could some matlab guru enlighten a newbie like me? Below are what appears on my matlab screen; >> 0.2+0.2+0.2+0.15+0.05==0.8 ans = 0 >> 0.2+0.2+0.2+0.14+0.06==0.8 ans = 1 >> 0.2+0.2+0.2+0.2==0.8 ans = 1 "sun" <sun@gmail.com> wrote in message <h2qav3$7um$1@reader01.singnet.com.sg>... > Dear ma... Invasion of the algorithms: The modern-day equations which can rule our lives "These are equations which, by processing huge amounts of micro-data, can predict our behaviour - but are they for better or worse? [...] As the so-called “internet of things” expands, billions of sensors will surround us, each of them a data point, each of them with algorithmic potential. The future requires us to place enormous trust in data scientists." Frack that. I'll hazard a guess that the "data scientists" will be investing a great deal of time convincing lawmakers, media moguls and CEOs that they are possessors of objective truths, or at least that ... Rule I got surprised when I saw that my Mathematica 7 computed FourierTransform[DiracComb[t], t, f] without trouble but couldn't deal with FourierTransform[DiracComb[2 t], t, f] So I thought about writing a rule that uses the property that the F{x[k t]}[f] = 1/|k| F{x[t]}[f/k] (I think :P) In Mathematica's words: FourierTransform[ expr_ , t_, f_] should be transformed, only if in "expr" you can find aall "t"s multiplied by the same thing (let's call it "k"), and that thing doesn't have "t"s inside, into 1/Abs[k] FourierTrnasfor... Rule Hi, How to create a rule which when an insert appears, update another row in another table with the value of the insert. for exemple : Table myins(col10,col11,col12) Table myupd(col20,col21,col22) When : Insert into myins(col10,col11,col12)VALUES(1,2,3); I want : update myupd set col21=col11, col22=col12 WHERE col20=col10; but if I write this rule like this : CREATE RULE regle1 AS ON INSERT TO myins DO update SET col21=NEW.col11, col22=NEW.col12 WHERE col20=NEW.col10; and i write Insert into myins(col10,col11,col12)VALUES(1,2,3); This rule update all the r... transforming a rule of lists to a list of rules Hello everyone. Does anyone know a way to transform a rule involving a list into a list of individual rules, that is to interpret the rule elementwise? For example, given {a,b,c} -> {0,3,x} is there a transformation which will turn this into {a->0, b->3, c->x} Thanks for the help! Ken Hello! Use: In[.]:=Inner[Rule,{a,b,c,...},{aa,bb,cc,...},List] Out[.];={a->baa,b->bb,c->cc,...} with kind regards Christoph On Wed, 30 Aug 2006 06:32:51 -0400 (EDT) Ken Senior <Ken.Senior@nrl.navy.mil> wrote: > Hello everyone. > ... pattern matching: rules that stop other rules? Hello. I've been using Mathamatica for quite a while but without ever finding out how the language works fundamentally, which I'm trying to do now. I'd be grateful for some help in understanding patterns - it seems like a powerful idea to me. There is something I can't work out. Define a function f [x_]:=0 say Now If [ p, 1, f [ 2] ] evaluates to itself. So the rule in the definition is not applied to f [ 2 ]. Replace If with some other undefined function, say qwerty, and you get qwerty [ p, 1, 0] not surprisingly. And If [ p, 1, f [ 2] ] /. f [x_]->0 returns If... spacing etc. with equations and equation arrays Hello all, I'm a little frustrated by two things in Latex, and I haven't been able to figure out how to deal with them by looking online. 1) I would like to be able to leave a blank line in the code before and after equations. That makes it much easier to find things when I'm looking for them during editing. The trouble is that when I do that it inserts spaces in the DVI file as well, or indents the following line so that it looks like the start of a new paragraph. 2) When I use the equation arrays, the lines are often very strangely lined up, and it looks bad. For instance, the... difference equations to solve wave equation i am new in matlab. Can any one help out in how to solve a the wave equation using finite difference methods(Say the five point method). I will be grateful. Thanks On May 13, 3:42=A0pm, "Kayanja Andy" <kayanja.and...@yahoo.com> wrote: > i am new in matlab. Can any one help out in how to solve a the wave equat= ion using finite difference methods(Say the five point method). I will be g= rateful. Thanks what have YOU done so far to solve YOUR particular problem... us "Kayanja Andy" <kayanja.andrew@yahoo.com> wrote in message news:hsgvjc$c11$1@f... replace one rule in a list of rules I have a list of simple rules. I want to repeatedly replace one of them. Is the best way to simply prepend the new rules, or is there a "prettier" approach? Thanks, Alan Isaac On Mar 17, 12:54 am, Kathryn Isaac <kathryn.is...@gmail.com> wrote: > I have a list of simple rules. I want to repeatedly replace one of > them. Is the best way to simply prepend the new rules, or is there > a "prettier" approach? > > Thanks, > Alan Isaac If all you want to change is the right-hand side of the rule then use RuleDelayed with a dummy right-h... Given an iterative equation to solve an equation An iterative equation for solving the equation x^2-x-1=0 is given by x(r+1)=1+(1/x(r)) for r=0,1,2,... Given x0=2, write a Matlab script to solve the equation. Sufficient accuracy is obtained when abs(x(r+1)-x(r))<.0005. I am a new to Matlab and I am having a hard time really even starting this problem. I was thinking that using some sort of loop until the accuracy condition is met would work. Any help would be much appreciated. Thanks in advance, Jacob "Jacob" wrote in message <kdf58n$958\$1@newscl01ah.mathworks.com>... > An iterative equation for solvin...

Abbreviations for begin{equation} ... end{equation}