5
$\begingroup$

I will ask a simple question and might have an issue on the site that explains better about it, but not found.

I am formulating a code that defines me an equation that I can generate a plot.

m = {{1, 1, 1}, {1, 2, 3}, {1, 4, 9}};
b = {1, 2, 3};
abc=LinearSolve[m, b]
f=abc[[1]]*x+ abc[[2]]*y+ abc[[3]]*z
sol=Solve[f==0,z]
Plot3D[sol,{x,0,15},{y,0,15}]

Or

Plot3D[z,{x,0,15},{y,0,15}]

I'm realizing that there is a mistake, but I do not know how to get an equation from LinearSolve output.

$\endgroup$

1 Answer 1

3
$\begingroup$

Solve is one of the functions that returns a list of rules and you need to use the /. Replace All command. Read: http://support.wolfram.com/kb/12505

m = {{1, 1, 1}, {1, 2, 3}, {1, 4, 9}};
b = {1, 2, 3};
abc = LinearSolve[m, b]
f = Dot[abc, {x, y, z}]
sol = Solve[f == 0, z]
Plot3D[z /. sol, {x, 0, 15}, {y, 0, 15}]

enter image description here

And as J.M. mentioned f= Dot [abc, {x, y, z}]is the same as f = abc[[1]]*x + abc[[2]]*y + abc[[3]]*z

$\endgroup$
17
  • $\begingroup$ You can use Dot[] to form the equation, of course. $\endgroup$ Jul 14, 2016 at 23:24
  • $\begingroup$ Really! Sometimes the answer is so easy that does pass shame. $\endgroup$
    – LCarvalho
    Jul 14, 2016 at 23:27
  • $\begingroup$ @LeandroMacieldeCarvalho No worries. Glad to help. $\endgroup$
    – Young
    Jul 14, 2016 at 23:32
  • 1
    $\begingroup$ mathematica.stackexchange.com/questions/1457/… $\endgroup$
    – Young
    Jul 15, 2016 at 0:30
  • 1
    $\begingroup$ "I do not know" - it was a hint for you to search the terms in a fabulous search engine, @Leandro. $\endgroup$ Jul 15, 2016 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.