Word Hacks [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Word Hacks [Electronic resources] - نسخه متنی

Andrew Savikas

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Hack 74 Use Fields for Heavy-Duty Calculations

By combining several types of Word fields, you
can perform some surprisingly complex calculations.

The built-in formula fields
[Hack #72]
give you most of the math power needed for typical Word work. But
what if you need something more sophisticated? With some
old-fashioned algebra, you can use those formula fields as building
blocks for more complicated calculations. This hack shows you two
such field combinations for calculating logarithms and a few
trigonometry functions.


To create field braces, you must press Ctrl-F9 or select
InsertField.

The line breaks shown in the field codes for this hack have been
added for readability. While not necessary, they make these mammoth
fields much easier to read and modify.


8.6.1 Logarithms


When you update the following
field, you're prompted to enter a number. The field
then calculates the log of the number you entered. Because Word does
not include a built-in log function, this hack uses a Taylor Series
Approximation to calculate the results.

{QUOTE
{SET l2l 0.301029995663981}
{SET l3l 0.477121254719662}
{SET l5l 0.698970004336019}
{SET l7l 0.845098040014257}
{SET l11l 0.0413926851582251}
{SET l13l 0.113943352306837}
{SET l17l 0.230448921378274}
{SET l19l 0.278753600952829}
{ASK z "What positive number do you want the log of?"}
{SET a{=abs(z)}}
{SET b{=9-(a<10^9)-(a<10^8)-(a<10^7)-(a<10^6)-
(a<10^5)-(a<10^4)-(a<10^3)-(a<10^2)-(a<10^1)-
(a<10^0)-(a<10^-1)-(a<10^-2)-(a<10^-3)-(a<10^-4)-
(a<10^-5)-(a<10^-6)-(a<10^-7)-(a<10^-8)}}
{SET c{=int(a/10^b)+mod(a,10^b)/10^b}}
{SET d{=(c<1.05)*0+(c>=1.05)*(c<1.2)*l11l+(c>=1.2)*(c<1.5)*l13l+
(c>=1.5)*(c<1.8)*l17l+(c>=1.8)*(c<1.95)*l19l+(c>=1.95)*(c<2.5)
*l2l+(c>=2.5)*(c<3.5)*l3l+(c>=3.5)*(c<4.5)*l2l*2+(c>=4.5)
*(c<5.5)*l50l+(c>=5.5)*(c<6.5)*(l2l+l31)+(c>=6.5)*(c<7.5)
*l7l+(c>=7.5)*(c<8.5)*l2l*3+(c>=8.5)*l3l*2}}
{SET e{=a-10^(b+d)}}
{SET f{=b+d+0.434294481903251*((e/10^(b+d))
-(e/10^(b+d))^2/2+(e/10^(b+d))^3/3-(e/10^(b+d)
)^4/4+(e/10^(b+d))^5/5-(e/10^(b+d))^6/6+(e/10^(b+d)
)^7/7-(e/10^(b+d))^8/8+(e/10^(b+d))^9/9-(e/10^(b+d)
)^10/10)}}
"The logarithm of {a} is {IF{=10^b}= a " "approximately "}{f}."}

As coded, the field gives results to 13 decimal places, which should
be enough for most purposes. If you need to calculate the logs of
larger or smaller values, increase the values in parameter
b (the exponent) accordingly.


References to constants in tables or bookmarks (as in the
SET fields used here to define certain logarithmic
values) need only be established once for the whole document.


8.6.2 Trigonometry


Word's formula fields
also
lack trigonometric functions, such as sine, cosine, and tangent.
Again, you can use Taylor Series Approximations to generate quite
accurate results (to 13 decimal places). Here's how
to create a table that will give you the sine, cosine, and tangent
values for a given angle, as shown in Figure 8-4.


Figure 8-4. Viewing the trig values calculated for an angle

First, create a new table in a Word document with four columns and
two rows. Title the first column Angle, the
second Sine, the third
Cosine, and the fourth
Tangent. In the second row, enter the field
codes for each value, shown in the next four sections.

To create the "Ø"
character, hold down the Alt key and type 0216 on the numeric keypad
[Hack #30] .

8.6.2.1 Angle


Enter the following field code in the second row of the
first column:

{QUOTE{ASK Ø "What angle do you want the trig values for?"}{Ø}}

8.6.2.2 Sine


Enter the following field code in the second row of the second column:

{QUOTE
{SET x{=0.0174532925199433*(1+MOD(Ø-1,90))}}
{SET SinØ{
=x-x^3/6+x^5/120-x^7/5040+x^9/362880-x^11/39916800+x^13/6227020800}}
{=SinØ*(1-MOD(INT(Ø/180),2)*2) \# 0.000000}}

8.6.2.3 Cosine


Enter the following field code in the second row of the third
column:

{QUOTE
{SET x{=0.0174532925199433*(1+MOD(Ø-1,90))}}
{SET CosØ{=1-x^2/2+x^4/24-x^6/720+x^8/40320-x^10/3628800+
x^12/479001600-x^14/87178291200}}
{=CosØ*(1-MOD(INT((Ø+90)/180),2)*2) \# 0.000000}}

8.6.2.4 Tangent


Enter the following field code in the second
row of the fourth column:

{QUOTE
{SET x{=0.0174532925199433*(1+MOD(Ø-1,90))}}
{SET TanØ{=(x-x^3/6+x^5/120-x^7/5040+x^9/362880-
x^11/39916800+x^13/6227020800)/(1-x^2/2+x^4/24-x^6/720
+x^8/40320-x^10/3628800+x^12/479001600-x^14/87178291200)}}
{IF{=(1+MOD(Ø-1,90))=90}= 1 "Infinite" {=TanØ*((1+MOD(Ø-1,90))
<>90)*(1-MOD(INT(Ø/180),2)*2)*(1-MOD(INT((Ø+90)/180),2)
*2) \# 0.000000}}}

To enter a new angle, select the entire table and press F9.

Paul Edstein


/ 162