Computer Science - MATLAB

thanks mathmate. It's way above my head to. I got another question

Consider the following two equations:

x^2 + y^2 = 42
x + 3y + 2y^2 = 6

Define a symbolic equation for each, and solve it by using MATLAB's symbolic capability. Could you solve these equations by using matrices? Try this problem twice, once using only integers in your equation definitions and once using floating-point numbers (those with decimal points). how do your results vary? Check the workspace window to determine weather the results are still symbolic.


I think that I may be doing something wrong because when I wrote out my code and ran it I got the same exact results when I tried using integers and when I included decimal points. I was hoping someone could explain to me what I'm doing wrong because I guess I'm suppose to get different results.

>> disp('No you could not solve this problem usign matrices.')
one=sym('x^2+y^2-42');
two=sym('x+3*y+2*y^2-6');
[x,y]=solve(one,two)
one=sym('x^2.0+y^2.0-42.0');
two=sym('x+3.0*y+2.0*y^2.0-6.0');
[x,y]=solve(one,two)
No you could not solve this problem usign matrices.

x =

-6.2161908711674029137999766546085
6.4782037201238076694174751205659
6.3321946913754454971273459117746
-5.594207540331850252744844377732


y =

1.8327495882457713513416277757555
-0.18131894709064188368251606877471
-1.3796051574695662000556283784362
-3.2718254836855632676034833285446


x =

-6.2161908711674029137999766546085
6.4782037201238076694174751205659
6.3321946913754454971273459117746
-5.594207540331850252744844377732


y =

1.8327495882457713513416277757555
-0.18131894709064188368251606877471
-1.3796051574695662000556283784362
-3.2718254836855632676034833285446

I was expecting my results to differ and to get the exact result when used integers and a estimate when I used digits with numbers. Do you know why this may have occurred? My friend ran the exact code on a much older version of MATLAB and produced the expected results, the exact answer were he entered digits

one=sym('x^2+y^2-42');
two=sym('x+3*y+2*y^2-6');
[x,y]=solve(one,two)

and a rounded answer when he didn't

one=sym('x^2.0+y^2.0-42.0');
two=sym('x+3.0*y+2.0*y^2.0-6.0');
[x,y]=solve(one,two)

we both can't seem to figure out why I'm not getting the same results when I run the same exact program in MATLAB

  1. 👍 0
  2. 👎 0
  3. 👁 68
asked by Lee
  1. The answers are correct (4 sets).

    Not sure how to explain the differences.
    You could try
    x=sym['x'];
    y=sym['y'];

    to force x and y to be symbolic variables
    before defining one and two.

    1. 👍 0
    2. 👎 0
  2. x =

    [ 33/4-1/4*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-1/4*6^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)-301*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+9*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2)-2*(-3/4+1/12*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+1/12*6^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)-301*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+9*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2))^2]
    [ 33/4-1/4*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+1/4*6^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)-301*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+9*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2)-2*(-3/4+1/12*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-1/12*6^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)-301*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+9*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2))^2]
    [ 33/4+1/4*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-1/4*(-(-330*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+6*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)+1806*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+54*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2)-2*(-3/4-1/12*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+1/12*(-(-330*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+6*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)+1806*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+54*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2))^2]
    [ 33/4+1/4*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+1/4*(-(-330*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+6*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)+1806*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+54*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2)-2*(-3/4-1/12*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-1/12*(-(-330*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+6*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)+1806*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+54*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2))^2]


    y =

    [ -3/4+1/12*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+1/12*6^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)-301*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+9*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2)]
    [ -3/4+1/12*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-1/12*6^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)-301*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+9*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2)]
    [ -3/4-1/12*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+1/12*(-(-330*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+6*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)+1806*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+54*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2)]
    [ -3/4-1/12*3^(1/2)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)-1/12*(-(-330*(2033+18*i*71413^(1/2))^(1/3)*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+6*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)*(2033+18*i*71413^(1/2))^(2/3)+1806*((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2)+54*3^(1/2)*(2033+18*i*71413^(1/2))^(1/3))/(2033+18*i*71413^(1/2))^(1/3)/((55*(2033+18*i*71413^(1/2))^(1/3)+2*(2033+18*i*71413^(1/2))^(2/3)+602)/(2033+18*i*71413^(1/2))^(1/3))^(1/2))^(1/2)]

    and this is what I was expecting to get when I ran it in matlab with digits and not floating point numbers but i dont

    1. 👍 0
    2. 👎 0
  3. I tried what you mentioned above and got the same results, an estimated value and not the above, my friend is also using a really old version of matlab

    1. 👍 0
    2. 👎 0
  4. This is strange.
    I checked the symbolic answers with a different software and I got at one time the same answer as your friend, with i in the answers and very complicated expressions, i.e. symbolic answers.
    After that, I get the numeric answers as you've got. I do not know if you have substituted the numeric answers into the equations to check. I did it for one case, and I got 10^-7 as residues, which is correct.
    I will see if I can check with the version of Matlab at university and find out what it gives.

    1. 👍 0
    2. 👎 0
  5. As a follow-up, here are some additional information.

    If you note that the second equation is linear in x, i.e.
    x + 3y + 2y^2 = 6 ...(2)
    can be rewritten as
    x = -3y + -2y^2 + 6
    which can then be substituted int the first equation
    x^2 + y^2 = 42 ...(1)
    to become
    (-3y + -2y^2 + 6 )^2 + y^2 = 42
    which is a quartic and soluble symbolically.
    The results are precisely what your friend got directly from an older version of Matlab.
    The values of y can then be substituted into the original equations (1) and (2) to solve for x.

    However, it is important to substitute these pairs of answers into both equations to make sure that they work, which is where Matlab comes in handy.

    So if Matlab does not give you the symbolic answers directly, you can still use Matlab to get the symbolic answers, with a little more elbow grease.

    It is possible that Matlab now defaults to answers by numerical methods, and using Newton's approximation in 2-d, it is possible to obtain answers of indefinite accuracy.

    Give it a try!

    1. 👍 0
    2. 👎 0
  6. Have you tried the muPad package? It is built into the Matlab and is a package for symbolic math.
    I tried your code on Matlab version 2010b and it gives only numerical answers as you got.
    I believe you need to use muPad or a special interpreting command if you want to stay in Matlab command line.

    1. 👍 0
    2. 👎 0

Respond to this Question

First Name

Your Response

Similar Questions

  1. Probability

    Thank you for the explanation MathMate! Would the answer to this question be A? Darby guesses the answers to six questions on the math portion of her college entrance exam. Each question is a true or false question. What is the

    asked by Student on March 4, 2012
  2. statistics

    this is to mathmate...this is jimmy and you answered by questions on random sample and probability (better business bureau question)..i greatly appreciate your help but i do not understand part b and d answers..i am totally lost

    asked by jimmy on July 22, 2012
  3. Math algebra

    I'm reposting this, because Mathmate's answer hasn't directed me to the WHY? part of the question. Any prompts appreciated. The product of any two (whole) numbers each of which leave a remainder of 1 on dividing by 7, also leaves

    asked by charlie on May 3, 2010
  4. French response

    Mathmate, I wrote a response below. The worksheet I worked on was a crossword puzzle and question 18 is only a five letter word and i'm not sure what it may be.

    asked by Lisa on August 31, 2009
  5. computers

    Hey mathmate is it posible to make the computer read my powerpoint presentation and thanks again for answering my other question

    asked by Nathan on September 26, 2009
  6. English

    1. What is the name for the head of an orphanage? 2. What is the name for the head of an nursery school? 3. What is the name for the head of a day-care center? 4. What is the name for the head of a senior center? 5. What is the

    asked by rfvv on August 21, 2013
  7. MATH

    cos(x)=2 and sin(x)=5 Thanks for your previous answers mathmate. No. It's not a typo. I was wondering if someone could explain to me when in real life would I need to solve such problems, or similar, besides answering problems

    asked by George on July 15, 2011
  8. Math

    Mathmate, I really appreciate all your help regarding my composite function question below but I'm still in need of your help. I don't understand how the range of x^2-x+1 is R. Isn't this a parabola with a minimum for y? Also, I

    asked by Sarah on September 25, 2010
  9. TO MathMate

    Adjectif masc sing fem sing fem Pl bete betes bete betes Mathmate I got some of them, but some are kind of hard okay 1st I'll put the masc form, then fem, then mas pl, then fem pl. diligents, diligente, diligentes paresseux,

    asked by Anna on October 1, 2009
  10. math

    I need help showing work. I did it in my head and now missing a huge part of how I got it. 110=2/3*8 my answer is 165 but they ask me to showwork, which I am always getting docked because as I read the question I do it in my head.

    asked by lucy on October 21, 2012
  11. Social Studies

    The question is "Evaluate the effectiveness of this action" The action was the government appologizing for Chinese Head Tax. Not only did the gov't appologize , it also gave symbloic payments to those affected by the head tax.

    asked by Brooke on November 15, 2011

More Similar Questions