|
That's beautiful, Peter. Thank you! God bless math wizards!
[EDIT]
A question:
The term (2-1) appears often. That makes no sense, so I'm guessing that it's an HTML encoding error. Can you clarify, please?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
modified on Thursday, June 24, 2010 2:56 AM
|
|
|
|
|
Actually a slightly more inspired approximation is
x - sin(x) = y
let q = pi/2
calculate b = (q^3/(q-1)-6)/(q-1) approx equal to 1.384269281
then
x = ((6 + b*y) * y)^(1/3)
is accurate to 0.47% for 0 <= y <= pi/2-1
follow this by one NR refinement (for y > 0)
x1 = x0 + (y - x0 + sin(x0))/(1 - cos(x0))
reduces relative error to less than 2 x 10^-5 over this range
two refinements gets relative error down to 4 x 10^-10
re the 2-1, just evaluate is as your compiler would, so pi/2-1 = (pi/2)-1
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
How are you making these approximations?
|
|
|
|
|
harold aptroot wrote: How are you making these approximations?
for x - sin(x) = y, for small y
x = (6y)^(1/3)
the first approximation is simply taking this form and making the value correct at the two ends of the interval, y in (0, ym) where ym = pi/2-1. x=0 for y=0, so we only have to make x=pi/2 at y=ym, so
x = pi/2 * (y/ym)^(1/3)
This gives about 4% error.
Noting that the scale factor is wrong at y=0, the second approximation is of the form
x = ((6+b*y)*y)^(1/3)
which is like x = (6y)^(1/3) for small y, and we choose b so that x=pi/2 for y=ym. This gives less than 0.5% error.
Add this to a simple excel spreadsheet to do a few NR iterations and calculate the errors and you are done.
I'm sure that you could improve things given enough time.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
cp9876 wrote: x = ((6+b*y)*y)^(1/3)
which is like x = (6y)^(1/3) for small y, and we choose b so that x=pi/2 for y=ym. This gives less than 0.5% error.
I'm sure that you could improve things given enough time.
Using the same b and ym as before, put
x = ((6+b*ym*(y/ym)^a)*y)^(1/3)
Run Excel's solver to optimise 'a' gives a = 0.731889437 for a relative error < 0.033%
One NR iteration reduces this to 1 x 10^-7
OK, I'm going to stop now....
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
How did you know what "form" the formula should have?
|
|
|
|
|
harold aptroot wrote: How did you know what "form" the formula should have?
if you are asking where the
x = (6y)^(1/3)
comes from, it is just a first order expansion around y=0
Just to summarise for Roger, the best approxmiation so far:
let q = pi/2
calculate b1 = (q^3/(q-1)-6)
ym = q-1
x = ((6+b1*(y/ym)^a)*y)^(1/3)
with a = 0.731889437
gives a relative error < 0.033%
One NR iteration reduces this to 1 x 10^-7
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Excellent! I have no clear idea about how it is derived, but that won't stop me from using what works.
When you refer to a first order expansion, what is it you're expanding? Taylor series?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Roger Wright wrote: When you refer to a first order expansion, what is it you're expanding? Taylor series?
Just do a Taylor expansion
x - sin(x) = x - (x - x^3/3! + ..) = y
as x->0 only the lowest powers are significant, so
x^3 / 6 = y
or x = (6y)^(1/3)
The rest of the approximation stuff is guesswork, and using something like Excel to see how well you are going. It's a bit of a game that's fun to play occasionally.
Using Excel and the solve function you can get a nice tidy approximation that's probably better for implementation:
x = (ay)^(1/3) + by + cy^2
a = 5.998854
b = 0.10235
c = 0.01579
the relative error is less than 2.7 x 10^-5 over the range 0 <= y <= pi/2 - 1
If you need better than this, one NR iteration gets you to 10^-10 territory and one more should pretty well get you full double precision.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
cp9876 wrote: If you need better than this, one NR iteration gets you to 10^-10 territory
I think that's probably close enough for sewer work.!
The recent one I did resulted in an argument - I specified a slope of 1.6%, and the job foreman insisted that they never use less than 33% ! It took me a while to figure out that he was talking about % of a degree, as displayed in his laser leveling instrument. The poor clod couldn't calculate a slope in ft/ft from degrees, so I wrote him up a tutorial showing the steps. Then the dumb bastard had the audacity to submit a bill for $1000 for the "change order."
Thanks for the assistance, and for reminding me how old I'm getting. I used to do these things in my head.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Roger Wright wrote: cp9876 wrote:
If you need better than this, one NR iteration gets you to 10^-10 territory
I think that's probably close enough for sewer work.!
I don't want even 10^-10 of your sewerage to end up in the wrong place!
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
How to x^2+y^2+z^2=g^2 if x^2+y^2=a^2 and x^2+z^2=b^2 and y^2+z^2=c^2?
Thanks.cheers!!
|
|
|
|
|
choose a single forum and stick to it!
|
|
|
|
|
ja tnx i understand.
cercare il pelo nell'uovo.
|
|
|
|
|
which are the values that are given and which are you looking for?
ok, suppose x,y,z are the unknown values and a,b,c,g are given
you have 3 unknowns and 4 equatations, so this is overdetermined (may also have no solution)
as all values go squared here, lets substitute
p = x^2
q = y^2
r = z^2
write it in lines:
p + q + r = g^2 (I)
p + q = a^2 (II)
p + r = b^2 (III)
q + r = c^2 (IV)
to get p for example, substract (IV) from (I)
(I) - (IV):
p+q+r-(q+r) = g^2 - c^2
p = g^2 - c^2
then do it similar to get r and q
after this, get each two values x1 und x2 like
x1 = sqr(p)
x2 = -sqr(p)
but I believe that there is no solution in this equatation, because after having the p,q,r try setting them in the first (p+q+r=g^2) and check if it is right - I dont think so
(edit: yeah code blocks...)
|
|
|
|
|
Thanks for your help and ideas.I even tried trial and error by hand for a couple of hours.I think it is a Diophantine equation and has solution but i 'm not good at this.I 'll check for it and come back.
|
|
|
|
|
you can help me help you by telling me which values are given and which you are looking for.
if a,b and c are given values (you know their value) and x,y,z and g are the unknown onesthen there exist multiple solutions
these solutions are in a hypercube, but an easier way of describing the solutions is:
- set g as parameter
- draw the plane of all (x,y,z) which satisfy the solution into a 3d grid
then you can visualize the (x,y,z)s for different gs
edit: I could solve it analyticly, but then where is the fun for you
eidt2:
my bad. forgot you have 4 equatations! with 4 eqs and 4 unknown values, there is a solution for each x^2, y^2, z^2 and g^2 !
just simple gauss algorithm
modified on Tuesday, June 15, 2010 8:15 AM
|
|
|
|
|
Could you think of the problem as a Pythagorean triangle in 3d space and the last 3 equations as projections of this triangle on the xy,xz,yz planes and find the right coordinates for the vertices of the triangle,because these equations remind me of the Pythagorean Theorem?
Tnx in advance.
|
|
|
|
|
this has got nothing to do with pythagoras.
it is now the third time I ask you: which values are you looking for??? is it x,y,z or x,y,z and g?
make life easier and replace all squares:
p=x^2,...,a^2=d,...g^2=h
p + q + r = h
p + q = d
p + r = e
q + r = f
does this look any pythagorean? no
now look for the gauss algorithm to solve linear equatations (or similar solvers)
|
|
|
|
|
you hit ht enail on the head - it looks much simpler now!
|
|
|
|
|
Assuming your instructor uses the convention that variable quantities are represented by x,y and z, and that constant values are represented by the values a,b and c:
g(x,y,z) = x2 + y2 + z2 and
x2 + y2 = a2
x2 + z2 = b2
y2 + z2 = c2
You have three equations in three independent variables, and one dependent equation based on the values of the variables from the first three. Solving first the independent equations:
x2 + y2 = a2
-(x2 + z2) = b2
y2 - z2 = a2 - b2
y2 - z2 = a2 - b2
+(y2 + z2 = c2)
2y2 = a2 - b2 + c2
y2 = (a2 - b2 + c2)/2
Substituting,
y2 + z2 = c2
(a2 - b2 + c2)/2 + z2 = c2
a2 - b2 + c2 + 2z2 = 2c2
2z2 = -a2 + b2 + c2
z2 = (-a2 + b2 + c2)/2
Again substituting,
x2 + z2 = b2
x2 + (-a2 + b2 + c2)/2 = b2
2x2 = a2 + b2 - c2
x2 = (a2 + b2 - c2)/2
Finally, returning to the dependent equation and substituting the determinant vales:
g(x,y,z) = x2 + y2 + z2 = (a2 + b2 - c2)/2 + (a2 - b2 + c2)/2 + (-a2 + b2 + c2)/2 = (a2 + b2 + c2)/2
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Yes but i'm looking for integer solutions and i want the number g(x,y,z)=x^2+y^2+z^2 to be a square of an integer number.
Tnx.
|
|
|
|
|
all that is true,
x2 + y2 + z2 = (a2 + b2 + c2)/2 is obvious when summing the three simpler equations
x2 + y2 = a2
x2 + z2 = b2
y2 + z2 = c2
but none of it brings us any closer to finding all possible solutions when x,y,z,a,b,c are all unknown.
The first step would be the introduction of a 2-D parameter space (u,v) that yields all solutions of a simple x2 + y2 = a2, then doing similar things to the others, and finally unite the conditions.
|
|
|
|
|
That might work, but as an engineer, armed with the new information that the OP is seeking integer solutions only, I'd simply write a program the cycles through all integer values of a, b, c then pick the results I like.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
that may take "a while" as there are infinitely many non-trivial solutions to the single equation x2+y2+z2=g2 (1,2,2,3 would be a simple one of them), and probably (I'm still looking into this) a non-zero fraction (hence also infinitely many) of those also satisfy the three extra conditions.
It really is a challenge that deserves a mathematical approach, not a brute-force one.
|
|
|
|
|