HP Forums
Funny math problem to calculate the Pin Number for a credit card. - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not remotely HP Calculators (/forum-9.html)
+--- Thread: Funny math problem to calculate the Pin Number for a credit card. (/thread-17345.html)



Funny math problem to calculate the Pin Number for a credit card. - Steve Simpkin - 08-10-2021 05:31 AM

This cute math problem to calculate the Pin Number for a credit card popped up on a post in the Facebook HP Calculator Fan Club group recently. Apologies if it has been posted before.

[attachment=9721]


RE: Funny math problem to calculate the Pin Number for a credit card. - Steve Simpkin - 08-10-2021 05:34 AM

Here is the solution to this problem using the free HP Prime Lite app.

[attachment=9722]


RE: Funny math problem to calculate the Pin Number for a credit card. - Steve Simpkin - 08-10-2021 05:41 AM

Here is the solution using a Casio fx-991EX.
I had to set the upper limit to .9999999999 (stored in Y) to avoid an error on this model.
At about $18 USD, this is probably the least expensive physical calculator currently available new that can solve this problem.

[attachment=9723]


RE: Funny math problem to calculate the Pin Number for a credit card. - Albert Chan - 08-11-2021 03:40 PM

(08-10-2021 05:41 AM)Steve Simpkin Wrote:  Here is the solution using a Casio fx-991EX.
I had to set the upper limit to .9999999999 (stored in Y) to avoid an error on this model.

FYI, integrand singularity (at x=1) is removable.

(3x^3-x^2+2x-4) / √(x^2-3x+2)
= (x-1)*(3*x^2+2*x+4) / √((x-1)*(x-2))
= -(1-x)*(3*x^2+2*x+4) / √((1-x)*(2-x))       // integral limits 0 to 1, √(1-x), √(2-x) both real
= -(3*x^2+2*x+4) * √(1-1/(2-x))

XCAS> -∫((3*x^2+2*x+4) * √(1-1/(2-x)), x=0..1)

(-202*sqrt(2) + 135*ln(2*sqrt(2)+3))/16        // ≈ -2.98126694401

---

Proof: assume integral have the form f*√g

(f*√g)' = f'*√g + f/(2√g)*g' = (f'*g + f*g'/2) / √g

XCAS> f := a*x^2+b*x+c          // integrand numerator is cubic, thus quadratic f
XCAS> g := x^2 - 3x + 2           // integrand denominator = √g
XCAS> coefs := e2r(f'*g + f*g'/2)

[3*a, (-15*a+4*b)/2, (8*a-9*b+2*c)/2, (4*b-3*c)/2]

Ignore constant term for now, we match 3 coefs with 3 unknown.

XCAS> a, b, c := 1, 13/4, 101/8
XCAS> coefs

[3, -1, 2, -199/16]                     // = [3, -1, 2, -4] - [0, 0, 0, 135/16]

I1 = preval(f*√g, 0, 1) = subst(-f*√g, x=0) = -101/8*√(2)

I2 = ∫(1/√(x^2-3x+2), x=0..1)            // let y = 2*(x-3/2)=2x-3, dy = 2 dx
    = ∫(1/√(y^2-1), y=-3 .. -1)             // ∫(1/√(y^2-1), y) = -ln(abs(-y+sqrt(y^2-1)))
    = ln(2*√(2)+3)

I = I1 + 135/16 * I2 = -101/8*√(2) + 135/16*ln(2*√(2)+3)


RE: Funny math problem to calculate the Pin Number for a credit card. - Werner - 08-12-2021 07:54 AM

You never cease to amaze me, Albert!
Took me only three reads to understand this time ;-)
Nice trick.

Cheers, Werner


RE: Funny math problem to calculate the Pin Number for a credit card. - Albert Chan - 08-12-2021 03:05 PM

(08-11-2021 03:40 PM)Albert Chan Wrote:  I2 = ∫(1/√(x^2-3x+2), x=0..1)            // let y = 2*(x-3/2)=2x-3, dy = 2 dx
    = ∫(1/√(y^2-1), y=-3 .. -1)             // ∫(1/√(y^2-1), y) = -ln(abs(-y+sqrt(y^2-1)))
    = ln(2*√(2)+3)

Another way is to map y=2*x-3 for the full integral, then solve by integration by parts
Note that above quoted expression, map from x to y, numerator of 1 stayed 1.

XCAS> e2r(r2e([3,-1,2,-4], (y+3)/2), y)       → [3/8, 25/8, 77/8, 55/8]

I = ∫((3y^3 + 25y^2 + 77y + 55) / √(y^2-1), y=-3 .. -1) / 8

Y0 = ∫(1/√(y^2-1),y) = -ln(abs(-y+√(y^2-1)))
Y1 = ∫(y/√(y^2-1),y) = ∫d(√(y^2-1)) = √(y^2-1)

Y2 = ∫(y^2/√(y^2-1),y) = ∫(y*d(Y1)) = y*Y1 - (Y2-Y0)
2*Y2 = y*Y1 + Y0

Y3 = ∫(y^3/√(y^2-1),y) = ∫(y^2*d(Y1)) = y^2*Y1 - 2*(Y3-Y1)
3*Y3 = (y^2+2)*Y1

3*Y3 + 25*Y2 + 77*Y1 + 55*Y0
= (y^2+2)*Y1 + 25/2*(y*Y1+Y0) + 77*Y1 + 55*Y0
= (y^2+25/2*y+79)*Y1 + 135/2*Y0

I = preval((y^2+25/2*y+79)*√(y^2-1) + 135/2*(-ln(abs(-y+√(y^2-1)))), -3, -1, y) / 8
  = -101/8*√(2) + 135/16*ln(2*√(2)+3)
  ≈ -2.98126694401


RE: Funny math problem to calculate the Pin Number for a credit card. - Don Shepherd - 08-12-2021 11:41 PM

I guess I just don't see the point. A credit card that requres a PIN number either comes with a pre-assigned PIN or lets you choose the PIN; most of mine let you choose. A calculated PIN would seem unnecessary in both cases.


RE: Funny math problem to calculate the Pin Number for a credit card. - Steve Simpkin - 08-13-2021 12:02 AM

(08-12-2021 11:41 PM)Don Shepherd Wrote:  I guess I just don't see the point. A credit card that requres a PIN number either comes with a pre-assigned PIN or lets you choose the PIN; most of mine let you choose. A calculated PIN would seem unnecessary in both cases.

I think the humor here is that the person writing the letter and being generous with their credit card (probably uncharacteristically for them) assumes their partner will not be able to solve the math problem and get the PIN number (probably 2981). I showed this to my wife and she laughed and then said "Ass".


RE: Funny math problem to calculate the Pin Number for a credit card. - Namir - 08-13-2021 05:30 AM

Solve on the HP15C gives pretty much the same value for the integral between 0 and 0.99999.


RE: Funny math problem to calculate the Pin Number for a credit card. - OlidaBel - 08-13-2021 07:52 AM

Hi,
Could someone test it on a real HP-42S ?
Because I've just tested in its swiss clone and I don't get error with [0, 1] boundaries ;-)


RE: Funny math problem to calculate the Pin Number for a credit card. - Werner - 08-13-2021 08:57 AM

It is well-known that the numerical integration in, I think, all its HP implementations (from 34C onwards) never evaluates the endpoints. Free42 and, by extension, the DM42 are such faithful simulators that they of course mimic that, too.
But I did try it out on a real 42S of course. No problem whatsoever.

Code:
00 { 41-Byte Prgm }
01▸LBL "FX"
02 MVAR "X"
03 RCL "X"
04 ENTER
05 STO ST Z
06 3
07 ×
08 1
09 -
10 ×
11 2
12 +
13 ×
14 4
15 -
16 X<>Y
17 X^2
18 3
19 LASTX
20 ×
21 -
22 2
23 +
24 SQRT
25 ÷
26 END

With ACC= 0.0001 I get -2.98125065973

Cheers, Werner


RE: Funny math problem to calculate the Pin Number for a credit card. - Albert Chan - 08-13-2021 05:26 PM

(08-12-2021 03:05 PM)Albert Chan Wrote:  I = ∫((3y^3 + 25y^2 + 77y + 55) / √(y^2-1), y=-3 .. -1) / 8

Another way, by regroup terms. (odd and even powers of y)

diff(y*√(y^2-1), y) = (2*y^2-1) / √(y^2-1))

I = ∫((3/8*(y^2-1)+10)*y/√(y^2-1), y=-3 .. -1) + ∫((25/16*(2*y^2-1)+135/16)/√(y^2-1), y=-3 .. -1)

For first term, let z = y^2-1, dz = 2y dy:

∫((3/8*(y^2-1)+10)*y/√(y^2-1), y) = ∫(3/16*√z+5/√z, z) = 1/8*z^(3/2) + 10*√z

I = preval((z/8+10)*√z,8,0,z) + preval(25/16*(y*√(y^2-1)) + 135/16*(-ln(abs(-y+√(y^2-1)))),-3,-1,y)
  = -22*√(2) + (150*√(2)+135*ln(2*√(2)+3))/16
  = -101/8*√(2) + 135/16*ln(2*√(2)+3)


RE: Funny math problem to calculate the Pin Number for a credit card. - toml_12953 - 08-13-2021 08:00 PM

(08-10-2021 05:31 AM)Steve Simpkin Wrote:  This cute math problem to calculate the Pin Number for a credit card popped up on a post in the Facebook HP Calculator Fan Club group recently. Apologies if it has been posted before.

I see an answer with a lot of decimals but what's the PIN?


RE: Funny math problem to calculate the Pin Number for a credit card. - johanw - 08-18-2021 12:19 AM

(08-13-2021 08:00 PM)toml_12953 Wrote:  I see an answer with a lot of decimals but what's the PIN?
The first 4 decimals?