Sorry for the lack of updates and posts to this web site. I have had a lot going on – and right now, we are in process of moving across the state. Eventually things will be settled down. I completed several interesting App Inventor projects but have lacked time to get them posted here. Hang in there – I intend to be back!
MIT has announced that the App Inventor for iOS (Apple iPhone and iPad) has entered beta testing. The Beta test program is currently limited, but is expected to expand in the summer, with a public release next summer.
This web site – appinventor.pevest.com – is no longer the primary web site for our App Inventor tutorials. However, this web site will remain here indefinitely as many people link to it, including search engines and my own e-books 🙂
The new, short and easy to remember URL is Learn2C.org as in “Learn 2 Code”
Unfortunately, for reasons I will not get into, it is not possible to integrate the two web sites together. So appinventor.pevest.com will remain “as is”, and Learn2C.org will become the primary focus point.
I am looking into having Learn2C automatically cross post to the appinventor.pevest.com web site but that has not yet implemented. But I’d like to do that for those that already follow the appinventor.pevest.com web site.
My apologies for not doing a lot of updates during 2018. I have already written some new code examples (Bluetooth LE anyone?) and am working on more in that area. These tutorials will appear once I have completed the entire series of example programs. There are also other items in the works that I cannot talk about yet.
First, the update to WordPress 5 did not go well with this web site. The web site is running WP 5 now but it has caused many problems, at least one of which I seem unable to work around or fix.
Second, I tried to reconfigure the web site for something I have been working on, but it appears what I wanted is not possible. This temporarily left the web site over night on 10 January 2019 (UTC) unable to handle incoming search links properly. I have backed out that change and search queries (via Google) should resume landing on the correct pages.
Third, around 31 December to 2 January, this web site was mostly inaccessible due to my ISP making a change to their network, which made their SQL database server inaccessible. This impacted multiple web sites, including the ISP’s own web site!
I am continuing to work on these issues with apologies for the inconvenience.
A reader asked a question about how square roots can be calculated, referring to an example in my Volume 1 Introduction to App Inventor e-book. He was confused by the explanation of how it works – so I have written an expanded explanation of the method for calculating a square root of a number.
You could use the built in Math function to find the square root of a number – and generally that is what you should do. But if you would like to learn a method of calculating the square root of a number – then read on!
2,000 years ago, Greek mathematicians identified a method of finding approximate square roots. The method makes an initial guess of a square root (which is often not even close to the right value) and then repeats a sequence of dividing and averaging which gradually refines the initial guess into an accurate square root. To find the square root of some number n, we set our initial guess to n (which we know is not correct), and then calculate an average of our guess with n divided by our guess.
To find the square root of 30, we initially guess the square root is 30 (which we know is wrong). We then take 30 and divide it by our guess, which in this case is 30. This gives us a value of 1. The average of our original number 30 and our divided value is 15.5. We select 15.5 as our new guess.
This little spreadsheet may help understand how the square root concept works.
To find the square root of 30, we initially guess the square root is 30 (which we know is wrong). We then take 30 and divide it by our initial guess, which is 30. This gives a value of 1. The average of our original number 30 and 1 is 15.5. We select 15.5 as our new guess on the next row down in the Guess column.
Then we repeat this and take 30 divided by our new guess of 15.5. This gives us 1.93548. We average our 15.5 guess with our new value of 1.9458 giving us 8.717, which becomes our new guess on the next row down.
We repeat again using 8.717 as our new guess and divide 30 by 8.717, giving us 3.44. We average the 8.717 with 3.44 giving us 6.0795, use that as our next guess.
When do we stop this repeating cycle? We could repeat this a set number of times, say six, and then stop. But a better solution is to specify how many digits of accuracy we would like to have in our answer.
Let’s say that 5.4 is accurate enough for our purposes. We could stop as soon as our new guess is within 0.1 of our prior guess. In our spreadsheet above, our generated guesses are:
As you can see, the correct answer has converged to 5.477 rather quickly. If we wanted an accuracy of just 1 digit to the right of the decimal point, we can stop once the difference between the current and previous guess is 0.1
The first digits of the last two guesses are the same 5.4 so we could stop with an accuracy of .1. In this particular calculation, we see that we are accurate to the thousandth’s place 5.477 as these values are no longer changing.
We stop the cycle when the difference between guesses becomes very small.
With our definition of small to 0.1, we stop at 5.4. If we set our definition of small difference to 0.001, then we stop at 5.477.
Here is some sample App Inventor code that calculates the square root. It fetches the number for which we find the square root from a user interface Text Box named txtDataEntry. We set NewValue (our initial guess) to this value. Then the code uses a while test loop to repeatedly do the calculation while the difference between our new guess and our previous guess is greater than 0.1 (you can change this to smaller values for greater accuracy).
This square root calculation repeats as long as the difference between our NewValue and OldValue are large.
As long as the difference remains large, the while test condition is “true”, and the code inside the while block continues to execute. However, once the difference becomes small, the test condition evaluates to “false” and the the execution of the “do” section stops. We have found our approximate square root.
App Inventor is the quick and easy way to write Android Apps