Linux - Taylor series

jephoxstar

New Member
Joined
Apr 23, 2021
Messages
2
Reaction score
0
Credits
24
Linux exo.JPG
 


As this looks like a homework question, nobody here is going to do it for you.
Make an attempt and let us know where you get stuck. It should be relatively straightforward.

The only things I will say are:
1. Bash can only perform integer mathematics. It cannot deal with real numbers (aka decimals).
So in order to facilitate the calculation, you will almost certainly need to use the bc command - a scriptable, terminal-based, arbitrary precision calculator.
Additionally, in order to get bc to perform maths with real/decimal values, you will need to start it with the -l option. Which tells it to load the full maths library instead of using basic integer maths.

2. The problem specifies that both numbers passed as parameters to the script should be positive. So don't forget to check the number of arguments passed to the script, and parse and range-check the passed-in parameters to ensure that they are valid inputs.
If there are any problems - e.g. wrong number of parameters, or invalid numbers - it would probably be an idea to display an error message.
 

Members online


Top