{"id":139,"date":"2017-09-13T10:27:11","date_gmt":"2017-09-13T13:27:11","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=139"},"modified":"2017-09-13T10:27:11","modified_gmt":"2017-09-13T13:27:11","slug":"mathin","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/mathin\/","title":{"rendered":"mathin"},"content":{"rendered":"<pre>(*  This file of Mathematica commands can be executed by Mathematica  *)\r\n(*  Lines that begin and end like this one are ignored by Mathematica *)\r\n(*  For best results put this file in your home directory             *)\r\n(*  Start Mathimatica from Unix by typing \"math\"                      *)\r\n(*  When you get a Mathimatica prompt type: \"&lt;&lt;mathin                 *)\r\n(*  I've added Mathimatica \"Print commands because Mathematica only   *)\r\n(*  the results of the last command in a file like this.  They also   *)\r\n(*  make results look a little better for a situation like this.      *)\r\n(*  However, you would normally not use them in an interactive session *)\r\n(*  Try typing variations on any other command you see here  *)\r\n(*                                                                     *)\r\nPrint [\" Find Solutions to the Equation: a x^2 + b x + c = 0\"]\r\n(*                                                                     *)\r\n(*  In the line below \"eqn1 = \" just gives a name to the equation that *)\r\n(*  will abbreiviate later commands  *)\r\n(*                                                                     *)\r\neqn1= a*x^2+b*x+c==0.\r\n(*                                                                     *)\r\n(*   Now generate a solution and name it soln1 *)\r\n(*                                                                     *)\r\nsoln1= Solve[eqn1,x]\r\n(*                                                                     *)\r\n(*   In an interactive session \"Solve[a*x^2+b*x+c==0,x]\" would be fine *)\r\n(*  Print to display the equation and solution *)\r\n(*                                                                     *)\r\nPrint [\"For the equation   \", eqn1]\r\nPrint [\"The solutions are:\",soln1]\r\n(*                                                                     *)\r\n(* I can now go back and set values for a, b, and c and solve again  *)\r\n(*                                                                     *)\r\na = 1\r\nb = -1\r\nc = -1\r\n(*                                                                     *)\r\nPrint [\"For \", eqn1]\r\nPrint [\"The solutions are:\", N[soln1]]\r\n(*                                                                     *)\r\n(* In the above print the Mathematica function N[ ], gives a decimal  *)\r\n(* answer for x.   Depending on how your defaults are set, you may    *)\r\n(* see answers that aren't too helpful without using N[ ]             *)\r\n(*   Solve is an algebraic solver and at some point in equation       *)\r\n(*   difficulty will give up.  Then you need to try NSolve or FindRoot *)\r\n(*   NSolve works for polynomial equations   *)\r\n(*                                                                     *)\r\nsoln1= NSolve[eqn1,x]\r\nPrint [\"For the equation   \", eqn1]\r\nPrint [\"The solutions are:\",soln1]\r\n(*                                                                     *)\r\n(*   For more complicated equations Mathematica will apply Newton's method *)\r\n(*   Remember that this requires an initial guess, and only finds one      *)\r\n(*   solution near the guess   *)\r\n(*   For a first guess of x = 3, the solution is obtained as follows:      *)\r\n(*                                                                     *)\r\nsoln1=FindRoot[eqn1,{x,3}]\r\nPrint [\"Newton solution starting from 3 is:\",soln1]\r\n(*                                                                     *)\r\n(*   Mathematica does an amazing number of things,  take a look at a book  *)\r\n(*   on the program for detailed information   *)\r\n(*   One useful function is integration:       *)\r\n(*                                                                     *)\r\nanswer1=Integrate[x^2*Sin[x],x]\r\nPrint[\"Indefinate integral of x**2 sin(x) is\"]\r\nPrint[answer1]\r\n(*                                                                     *)\r\n(*   You can also do definate integrals   *)\r\n(*                                                                     *)\r\nanswer2=Integrate[x^2*Sin[x],{x,0,Pi\/2}]\r\nPrint[\"Integral of x**2 sin(x) from 0.0 to pi is\"]\r\nPrint[answer2,\" = \",N[answer2]]\r\n(*                                                                     *)\r\n(*   If Mathematica refuses to use Integrate to evaluate a definate Integral *)\r\n(*   try the numerical integrator NIntegrate  *)\r\n(*                                                                     *)\r\nanswer2=NIntegrate[x^2*Sin[x],{x,0,Pi\/2}]\r\nPrint[\"Numerical Integral of x**2 sin(x) from 0.0 to pi is\"]\r\nPrint[answer2]\r\n(*                                                                     *)\r\n(*   Another useful operation is symbolic differentiation    *)\r\n(*                                                                     *)\r\nanswer3=D[x^2*Sin[x],x]\r\nPrint[\"Derivative of x**2 sin(x) with respect to x is\"]\r\nPrint[answer3]\r\n(*                                                                     *)\r\n(*  Check you course notes for more mathematica commands and play with them *)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>(* This file of Mathematica commands can be executed by Mathematica *) (* Lines that begin and end like this one are ignored by Mathematica *) (* For best results put this file in your home directory *) (* Start Mathimatica from Unix by typing &#8220;math&#8221; *) (* When you get a Mathimatica prompt type: [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-139","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/comments?post=139"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/139\/revisions"}],"predecessor-version":[{"id":140,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/139\/revisions\/140"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}