Well it’s not valentines day! But I just crossed my 5th wedding anniversary so it’s apt to do some heart warming geeky thing.

The above heart is rendered by pgplot from a program written in fortran.

The magic happens because of this little equation

y= sqrt(cos(x))*cos(200*x) + sqrt(abs(x)) – 0.7 * (4.0 – x*x)^0.01

-2.0>x<2.0

Here’s the complete program.

**PROGRAM** HEART

**USE IFQWIN**

**TYPE**(QWINFO) :: WINFO

**INTEGER(4)** :: RESULT

**INTEGER** :: PGOPEN

**REAL** XR(4000),YR(4000)

WINFO%TYPE=QWIN$MAX

RESULT= **SETWSIZEQQ**(QWIN$FRAMEWINDOW,WINFO)

RESULT=**ABOUTBOXQQ**(“HEART IN PGPLOT\RSUKHBINDER SINGH\RVERSION 1.0″C)

**IF**(PGOPEN(‘?’) .LE. 0) **STOP**

XR(1)=-2.0

XINC=0.001

YR(1)=(COS(XR(1)))**0.5 * COS(200*XR(1)) + (ABS(XR(1)))**0.5 -0.7 * (4.0 -XR(1) * XR(1))**0.01

**DO** I=2,4000

XR(I)=XR(I-1)+XINC

YR(I)=(COS(XR(I)))**0.5 * COS(200*XR(I)) + (ABS(XR(I)))**0.5 -0.7 * (4.0 -XR(I) * XR(I))**0.01

**END DO**

**CALL** PGENV(-2.0,2.0,-2.0,1.5,1,-1)

**CALL** PGSCI(2)

**CALL** PGPT(4000,XR,YR,1)

**CALL** PGCLOS

**END PROGRAM**

Showed it to my wife. From her quizzical look, I guess a real heart shaped gift would have been more appropriate! ๐ Lesson learnt ๐

Thanks walkingrandomly

### Like this:

Like Loading...

*Related*

You’re welcome ๐

LikeLike

Wish you all the best. May you share your time together.

Priyankar

LikeLike

Thanks ๐

LikeLike

Pingback: Did I Miss Valentine’s Day? « SukhbinderSingh.com