This is a topic that many people are looking for. thevoltreport.com is a channel providing useful information about learning, life, digital marketing and online courses …. it will help you have an overview and solid multi-faceted knowledge . Today, thevoltreport.com would like to introduce to you Matlab Essentials – Sect 15 – Factorial, Square Roots, and nth Roots. Following along are instructions in the video below:
hello and welcome to the section of the MATLAB tutor in this section were going to concentrate on learning about factorials and square roots and how to kind of manipulate all that stuff in terms of MATLAB so the easiest one to cover first something you probably wont use that much but you might you might use it and thats the factorial how to take factorial of something you might think that you would do something like 5 factorial but it doesnt understand what that is so what you need to do to do a factorial is you need to literally type in factorial and pass it as an argument past the number that youd like to take the factorial of so it literally does all the math 5 times 4 times 3 times 2 times 1 you get 120 so basically thats how you use the factorial command its pretty straightforward now now that thats out of the way I mean you know factorial is not something youll use all that much but occasionally when you define sequences and series in calculus youll be using the factorial guy so this is where you you where you get that information and if you forget you can always go here and type in factorial and hover over this guy and itll tell you its factorial you pass in or n is a scalar which is a number product on all the integers to 1 to N and it gives you all the information about what exactly its doing all right let me go and clear the screen that just took a few minutes now what Id like to spend a little bit more time is how to take square roots and also Im going to get into cube roots and in throats and things like that because those are things that youll be using pretty frequently in MATLAB I thing theres no
square root button anywhere on the screen here so what you need to remember is to do a square root you type in sq RT square root so lets do something simple square root of 4 is 2 so MATLAB understands the square root operator the square root of 81 is going to give you 9 if you put something in there thats not a perfect square like square root of 80 lets say then its just going to give you the decimal answer and thats perfectly fine now what if youd like to express the square root but not do it in terms of the square root function just as a reminder you can always go 81 raise to the power of 1/2 because as you all know when you raise something to the power of 1/2 its exactly the same thing as taking the square root so I can come up here and say 9 to the power of 1/2 and give me 3 so theres really two different ways to do square roots and it just depends on what you want to do using the sq RT command may be a little bit more readable it just depends on exactly what youd like to do now if youd like to take a root of of a number thats not a square root maybe you want to take a cube root or a fourth root or a fifth root there is a function for that and to demonstrate I want to show you how you might use the help system if you happen to forget the syntax so you just type this end type in nth root ok there is a power called function called enth root of real numbers so it says you pass it two values the first one is a number the second one is whatever root youre trying to take and it should return the
end through so lets type in in root all right lets type in something we know I know I happen to know that the cubed root of 8 is is something that we can easily find so the first number you pass it is the number you want to take the root of the second number you pass it is what root it is so in this case its a third root or cube root so were going to go in hit enter and the answer is 2 the reason its 2 is because 2 times 2 times 2 gives you 8 let me recall the last command another nice cube root that I just happen to remember is the cube root of 27 which is 3 because 3 times 3 times 3 is 27 so thats thats kind of nifty now also those of you this high up in math also know that you can do things like taking 27 raised to the power of 1/3 much like 1/2 gave us a square root before raising something to the 1/3 power will give you a cube root its mathematically the same thing okay so if you wanted to do something like 2 cube root of 8 you could do it that way so you can definitely handle all of this stuff by just raising things to fractional powers the only thing is it kind of sacrifices a little bit of readability but you know you can totally do it if you want to use the square root command thats fine if you want to use the in through command thats totally fine too those are all available to you now Id like to clear the screen really quickly and turn your attention to using the square roots functions when you have a basically a symbolic system going on here when you want to treat it perfectly a lot of times
in algebra you have the square root of 40 or something like that and you like you know you do the factor tree and you like to figure out what what that is equal to so obviously you can go square root of 40 right and youll get a number I know the answer six point three two four six but if you wrap that in a symbol square root of 40 right so now its doing square root of 40 but the answer basically is going into the symbol operator so its trying to keep everything exact and when you do that the symbolic math toolbox kicks in because we did this symbol operator here and the answer we get is not a decimal we get something more perfect than that two times ten to the one-half and if your heart if its hard for you to read that I mean its fine for me but if its hard for you to read that you can type in pretty answer and youll see two times ten to the one-half now you should know that anything to the one-half is just a square root so really what we have is two times the square root of 10 2 times the square root of 10 and we all learn in algebra how to factor 40 and get all the common things and do all this by hand but you can use MATLAB to keep everything perfect as well so you know if you wanted to do something you know taking the square root of 40 is not a big deal but what if you wanted to take the square root you know the perfect square root of you know something large like this lets see what MATLAB does okay very exact answer all right it keeps everything as exact as it possibly can notice that this is a huge numerator divided by
huge denominator if we want to convert it to a decimal then this is going to be the square root of that large number then go ahead and clear the screen to declutter our screen what if we wanted to do as another test symbolic representation of the square root of lets say 1050 something large this is something that would take you a little while by hand to actually factor it all out select all the terms and figure out what it all is lab quickly tells you its five times 42 to the power of 1/2 which if you want to visualize that a little bit better thats five times 42 to the power of 1/2 so five times the square root of 42 is going to be that answer and if you require that in decimal form you can always just type double answer it basically converts whatever you want to a decimal so the answer is 32 point four zero three seven all right so that about covers everything Id like to cover in this section we learned how to take the factorial of a number weve learned how to take the square root weve learned how to take the intrude and weve learned how to use the symbolic math toolbox to manipulate square roots to simplify them into exact form which is something thats pretty common actually you might need to do and then if we need to we can take these answers and convert them back to decimal as well so the nice thing about MATLAB is you have the flexibility of both you can work in decimals thats sort of the default mode thats fine if you want to deal in pure math terms you have that option as well just takes a little bit of time to understand how to talk to MATLAB to get it to do what you like it to do
Thank you for watching all the articles on the topic Matlab Essentials – Sect 15 – Factorial, Square Roots, and nth Roots. All shares of thevoltreport.com are very good. We hope you are satisfied with the article. For any questions, please leave a comment below. Hopefully you guys support our website even more.