# Math Methods

PIC specific math@ (including trigonometric functions sin(), arctan(), etc.), SX specific math@, Intel specific math@

Dr Dobbs Journal #271 pg 18 "A Conversation with William KahanWilliam Kahan "Formulas that are numerically stable are sometimes quite inelegant. Formulas that give you greater accuracy are sometimes full of cases, ugly cases.... F(x)=(sin x)/x  .... F(x)=(sin x)/x if x != 0 and F(0) = 1"

Have ex-mathematicians become dysfunctional?

Books

• "Statistical Distributions" by NAJ Hastings and J.B.Peacock John Wiley 1974 ISBN 0-470-35889-0 This rare book is essential for anyone doing MonteCarlo simulations or using Random Number sequences. It is a collection of simple algorithms for generating random numbers with specific distributions given a simple random number generator with good first and second order distribution.

Math:

If you've got a basket with 3 oranges in it and you take 5 out, then you have to put 2 oranges in again in order for it to be empty. -- Peter Gutmann

Questions:

• taking the square (x^2) with PIC-specific math
• Nicolaas Gerhardus Scheepers of ElectronCraft asks:
Hi there, I am having trouble with arithmetic in assembler. I want to do the following calculation:
Y = ((X-Xmin)((Ymax-Ymin)/(Xmax-Xmin))) + Ymin This is a formula to scale a point between Xmax and Xmin to a point between Ymax and Ymin. The Y points is 8-bit but the X points can be up to 16-bit values. You can already see my problem because I cannot get any 16-bit divided by 16-bit algorith or for that matter 24-bit divided by 16-bit that replies with the fractional part. So I came up with the next formula to try and use a 16-bit divided by 8-bit number to give back fractions:
Y = ((X-Xmin)(1/(Xmax-Xmin)/(Ymax-Ymin))) + Ymin But it just gets more complex as I go along. My second problem is that say I work out the division and now I must multiply the answer (which is fractional , how the hell do you do it with the fractional part. Do you first multiply both numbers so they are integer and then divide it again later with the same number or what. Am I even on the right track here or am I going bananas? Please help me I am now three months into the game and have learned a lot in a short space of time but the learning just seems to grow and not level out, not that I am complaining just a remark:-)

Rearrange the formula so that the top and bottom of the fraction is kept seperate. What you really want is:

Y = ((X-Xmin)(Ymax-Ymin) + Ymin(Xmax-Xmin)) over Xmax-Xmin.

Now you can do the top and bottom seperatly. Multiplying by a fraction is a seperate job but can still be done without division. It is a good idea to reduce the fraction after each operation to prevent overflow. A method for doing that is available but I can't find it at the moment.

Once you have the final answer, then you do the division.

Interested:

See:

• ankganit aaharik and salrya ankganit diff.

+

 file: /Techref/method/math.htm, 12KB, , updated: 2018/11/14 16:18, local time: 2018/12/11 06:46, TOP NEW HELP FIND:  52.91.245.237:LOG IN

 ©2018 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?Please DO link to this page! Digg it! / MAKE! /  Methods in Math

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
 Did you find what you needed? "cos" "No. I'm looking for: " "No. Take me to the search page." "No. Take me to the top so I can drill down by catagory" "No. I'm willing to pay for help, please refer me to a qualified consultant" "No. But I'm interested. me at when this page is expanded."

 PICList 2018 contributors: o List host: MIT, Site host massmind.org, Top posters @20181211 RussellMc, Van Horn, David, Sean Breheny, David C Brown, Neil, Isaac M. Bavaresco, Bob Blick, Harold Hallikainen, AB Pearce - UKRI STFC, John Gardner, * Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr.

.