Draw/plot a heart graph

45

11

Your challenge is to draw/plot one of the hearts below. The size must be at least 50x50 pixels (vector graphics is OK). You may choose which of the hearts you want to draw/plot. Axes, grid lines etc. are accepted. There must be at least 100 distinct coordinates/points on the graph. The heart can be filled with color if you want to.

enter image description here

The equations are either:

enter image description here

or

enter image description here

enter image description here

t is in the range [-1, 1].

or

enter image description here

or

enter image description here

This is so the shortest code (in each language) in bytes wins. Please provide the output (or link to an online interpreter).

Stewie Griffin

Posted 2017-02-13T13:10:25.730

Reputation: 43 471

Answers

66

TI-80 BASIC, 45 43 41 39 bytes

LBL 1
RAND4-2->X
RAND4-2
IF (X²+ANS²-1)³<X²ANS³
PT-ON(X,ANS
GOTO 1

enter image description here

This took a while, and my battery is low so I didn't want to keep going.

I tried to use the second equation, but couldn't get it to work it actually turned out to be longer, so I just adapted the other answer I had.

EDIT: I just noticed the 50x50 pixel requirement, unfortunately the screen is only 47 pixels high so this isn't possible.

12Me21

Posted 2017-02-13T13:10:25.730

Reputation: 6 110

1creative indeed! – dalearn – 2017-02-13T17:13:26.860

8It's been a while, but can you replace IF (X²+ANS²-1)³-X²ANS³<0 with IF (X²+ANS²-1)³<X²ANS³? – wchargin – 2017-02-15T03:58:40.440

Oh, I can't believe I didn't think of that! thanks – 12Me21 – 2017-02-15T13:04:17.647

45

Perl, 86 bytes

$y=1-$_/25,say+map$y**3*($_*=$_/1e3)-($_+$y**2-1)**3>0?$|--?v60:3:$",-40..40for-6..50

Run with perl -E.

Plots a filled ASCII heart, using the first equation. Note that the x-axis is stretched by a factor of ~1.265: this is to counteract the fact that terminal fonts are usually much bigger vertically than horizontally.

Output:

                3<3<3<3<3<3<3<                   3<3<3<3<3<3<3<                 
              3<3<3<3<3<3<3<3<3<3<           3<3<3<3<3<3<3<3<3<3<               
            3<3<3<3<3<3<3<3<3<3<3<3<       3<3<3<3<3<3<3<3<3<3<3<3<             
          3<3<3<3<3<3<3<3<3<3<3<3<3<3<   3<3<3<3<3<3<3<3<3<3<3<3<3<3<           
         3<3<3<3<3<3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<          
        3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3 <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<         
       3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3        
      <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<       
      3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3       
     <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<      
     3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3      
    <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<     
    3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3     
    <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<     
    3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3     
    <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<     
   3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3    
   <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<    
    3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3     
    <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<     
    3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3     
    <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<     
    3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3     
     <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<      
     3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3      
     <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<      
      3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3       
      <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<       
       3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3        
       <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<        
        3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3         
         <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<          
         3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3          
          <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<           
           3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3            
            <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<             
             3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3              
              <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<               
               3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3                
                <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<                 
                 3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3                  
                  <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<                   
                   3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3                    
                     <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<                      
                      3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3                       
                       <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<                        
                         3<3<3<3<3<3<3<3<3<3<3<3<3<3<3                          
                           <3<3<3<3<3<3<3<3<3<3<3<3<                            
                            3<3<3<3<3<3<3<3<3<3<3<3                             
                              <3<3<3<3<3<3<3<3<3<                               
                                3<3<3<3<3<3<3<3                                 
                                  <3<3<3<3<3<                                   
                                    3<3<3<3                                     
                                     <3<3<                                      
                                       3                                        

Explanation (since OP asked for it):

condition := $y**3*($_*=$_/1e3)-($_+$y**2-1)**3>0

This is simply the first equation, slightly rearranged to make it shorter. $y directly represents the y in the formula. $_ is initially proportional to x, but is multiply-assigned with itself ($_*=$_/1e3), making it proportional to x². Since x² is used twice in the formula, this saves a few bytes.

1e3 means 1000, and was picked because it’s short and the result looks good. ** is Perl’s power operator. I use >0 rather than ==0 because I want a filled heart.

flip_flop := $|--?v60:3

v60 is an abuse of the archaic version-string syntax to denote the character with ASCII code 60: '<'.

$| is a magical variable that can only ever be 0 or 1. Decrementing when it’s already 0 sets it to 1. Decrementing when it’s 1 naturally sets it to 0. Thus, $|-- is often used as a flip-flop: each time it’s evaluated, it alternates between true and false.

As a whole, this expression returns alternatively '<' and 3.

inner_loop := <condition> ? <flip_flop> :$"

Nested ternaries. If condition is false (→ we’re outside the heart), evaluates to $", which is a magical variable that defaults to " " (a single space). If condition is true (→ we’re inside the heart), it evaluates flip_flop.

outer_loop := say+map <inner_loop> ,-40..40

Evaluates inner_loop repeatedly, with $_ (Perl’s “default” variable) going from -40 to 40, in increments of 1. It collects the results of those evaluation in a temporary list, then prints them all, concatenated, ending with a new line.

$y=1-$_/25, <outer_loop> for-6..50

This runs outer_loop repeatedly, with $y going from 1.24 (1 - (-6 / 25)) to -1 (1 - 50 / 25), in decrements of 0.04.

Note that y is divided by 25, while x² is divided by 1000, which is the same as dividing x by sqrt(1000). The ~1.265 factor I mentioned is sqrt(1000) / 25.

Grimmy

Posted 2017-02-13T13:10:25.730

Reputation: 12 521

5Huh, I guess it doesn't violate any rules... My favorite so far :) I'd love an explanation though :) – Stewie Griffin – 2017-02-13T17:01:01.050

1I'm confused about something. Why use ?v60 over, say, "<"? – Fund Monica's Lawsuit – 2017-02-13T21:44:15.287

Same length, but easier to type. – Grimmy – 2017-02-14T07:39:54.910

A heart made from hearts. – TheWanderer – 2017-02-14T12:29:03.300

34

Mathematica WolframAlpha, 17 15 13 11 bytes

Shaved off 2 bytes thanks to Martin Ender (1st heart curve -> heart curve 1)

Shaved off another 2 bytes thanks to Martin Ender (heart curve 1 -> heartcurve1)

This is probably cheating (the obvious solution), but here goes.

heartcurve1

Try it here!

I'm sure there's a way to shorten 1st, heart or curve such that Wolfram still accepts it. Well it's free of spaces now, maybe some sort of abbreviation for heart?

Do I get bonus points for plotting 2 of them?

heartcurves

Try that here!

Thunda

Posted 2017-02-13T13:10:25.730

Reputation: 1 151

5heart curve 1 – Martin Ender – 2017-02-13T13:34:43.993

6Actually, heartcurve1 works. – Martin Ender – 2017-02-13T13:35:21.717

23@MartinEnder What in the world – Thunda – 2017-02-13T13:36:36.773

1first one of heartcurves looks more like a butt though – Mikhail V – 2017-02-14T22:17:49.463

@MikhailV 0th heartcurve (cardoid) looks like a butt. – Thunda – 2017-02-15T08:31:38.123

it's a buttoid :-) – Mikhail V – 2017-02-15T14:57:23.753

29

Mathematica, 52 bytes

RegionPlot[(x^2+y^2-1)^3-x^2y^3<0,{x,-2,2},{y,-2,2}]

enter image description here

We could save one more byte with ContourPlot but then the background gets a bit trippy:

ContourPlot[(x^2+y^2-1)^3-x^2y^3,{x,-2,2},{y,-2,2}]

enter image description here

For one additional byte we could use the fourth formula and PolarPlot instead:

PolarPlot[(x=Sin@t)Abs@Cos@t^.5/(x+7/5)-2x+2,{t,0,7}]

enter image description here

Martin Ender

Posted 2017-02-13T13:10:25.730

Reputation: 184 808

23"A bit trippy" is a bit of an understatement... – Mego – 2017-02-13T13:41:47.477

ContourPlot triggers OCD so much. Aaaaaah! :D – KeyWeeUsr – 2017-02-15T09:19:23.837

25

Casio fx-7700GH, 21 bytes

sin θ √ Abs cos θ ÷ ( sin θ + 7 ÷ 5 ) - 2 sin θ + 2

Unnamed graph function to be entered into one of the polar coordinate graphing function slots, then does what it says on the tin.

The graphing range must be manually set (unless it happens to fit to the current set range), I set it to Xmin=-2.75, Xmax=2.75, Ymin=-4, Ymax=1.

Should work on other Casio Power Graphic Series calculators too, and quite possibly later Casio graphic calculators.

A heart drawn by a Casio fx-7700GH calculator (yep I'm pretty old and dusty)

Jonathan Allan

Posted 2017-02-13T13:10:25.730

Reputation: 67 804

18

MATLAB / Octave, 31 bytes

ezplot('(x^2+y^2-1)^3-x^2*y^3')

enter image description here

Suever

Posted 2017-02-13T13:10:25.730

Reputation: 10 257

9

SmileBASIC, 85 81 bytes

X=RNDF()*4-2Y=RNDF()*4-2GPSET X*50+99,Y*50+99,-(-X*X*Y*Y*Y>POW(X*X+Y*Y-1,3))EXEC.

enter image description here

12Me21

Posted 2017-02-13T13:10:25.730

Reputation: 6 110

9

Desmos, 20 16 15 bytes

V 2:

xx).3y=xx+yy-1

( = xx)^.3y=xx+yy-1)

V 1:

xx+yy-1)3=xxy3

V 0:

(x2+y2-1)3=x2y3

Daniel

Posted 2017-02-13T13:10:25.730

Reputation: 6 425

you could use xx instead of x^2 – 12Me21 – 2017-02-15T14:47:00.140

@12Me21, oh that's excellent, thanks! – Daniel – 2017-02-15T15:05:45.160

Your byte count is wrong, you have an extra newline. – Rɪᴋᴇʀ – 2017-02-16T21:46:26.713

@Riker, I don't see how it's wrong. Where is there a newline? – Daniel – 2017-02-16T21:47:01.907

http://imgur.com/a/4eTyt V2 is 14 bytes – Rɪᴋᴇʀ – 2017-02-16T21:47:34.580

@Riker, ah you forgot the ^. It's really xx)^.3=xx+yy-1 – Daniel – 2017-02-16T21:49:07.110

@Dopapp then your answer is wrong..... – Rɪᴋᴇʀ – 2017-02-16T23:09:50.510

@Riker, no. As you can see the .3 is a superscript, hence an exponent... – Daniel – 2017-02-16T23:25:41.737

@Dopapp wait, so is that 2 bytes? If so, can you just change it to ^3? It's the same amount of bytes, and clarifies for people reading the answer. – Rɪᴋᴇʀ – 2017-02-16T23:27:37.067

@Riker better now? – Daniel – 2017-02-16T23:31:09.620

7

MATL, 36 bytes

1e4t:w/EqXJX,JY,J|Yl**JX,X^J|.3^*&XG

Try it at MATL Online

enter image description here

Suever

Posted 2017-02-13T13:10:25.730

Reputation: 10 257

9Tfw MATL solution is longer than MATLAB :) – brainkz – 2017-02-14T11:00:00.080

7

Python, 119 116 bytes

from turtle import*
from math import*
t=1
while-t<1:a=abs(t);c=cos(t);goto(sin(t)*c*log(a)*99,c**.5*a**.3*99);t-=.01

Try it online

x=sin(t)*cos(t)*log(abs(t))

y=cos(t)**.5*abs(t)**.3

mbomb007

Posted 2017-02-13T13:10:25.730

Reputation: 21 944

6

SageMath, 66 bytes

polar_plot(sin(x)*abs(cos(x))^.5/(sin(x)+7/5)-2*sin(x)+2,(0,2*pi))

Try it online

Unfortunately, the long names of implicit_plot and parametric_plot (plus the need to define a variable other than the implicitly-defined x for the former) make the first three options much too long to be considered.

Thanks to busukxuan and Andrea Lazzarotto for a byte

Mego

Posted 2017-02-13T13:10:25.730

Reputation: 32 998

1Does ^.5 work in place of **.5? – busukxuan – 2017-02-14T03:49:26.773

1@busukxuan Nope. Sage is built on Python, and ^ is XOR. – Mego – 2017-02-14T05:59:42.907

1But sage substitutes ^ with **. I was wondering if it was because it couldn't substitute correctly if followed by a . – busukxuan – 2017-02-14T06:03:04.687

@busukxuan Sage uses Python's power notation (**). If you tried to use ^, you'd end up with a warning and an incorrect result. – Mego – 2017-02-14T11:14:48.103

I took a screenshot. I don't get it, could it be version differences?

– busukxuan – 2017-02-14T11:23:20.037

@busukxuan Possibly. The online sagecell I used for the permalink is running an older version of Sage, and I don't really have a way to run a newer version right now outside of SageMathCloud. – Mego – 2017-02-14T11:24:39.157

@Mego Sage treats ^ as an exponentiation. Always did that and it works in the Sage Cell link you posted as an example. :) Check it out here.

– Andrea Lazzarotto – 2017-02-14T19:44:01.010

1@AndreaLazzarotto Then apparently my memory is faulty. Thanks. – Mego – 2017-02-14T20:41:38.727

6

C, 137 133 bytes

p;float x,y,f;v(){for(p=4e3;p;x=(float)(p%99-50)/35,y=(float)(p/40-45)/40,f=x*x+y*y-1)putchar(p--%99?f*f*f-x*x*y*y*y<1e-3?35:32:10);}

http://codepad.org/zqqYUui8

Thanks @AlbertRenshaw, I also changed the 100s to 99s for 2 more bytes

Ahemone

Posted 2017-02-13T13:10:25.730

Reputation: 608

1+1; I like the use of v for the function, good flair. You can shave two bytes by replacing 4000 with 4e3 and replacing 0.001 with 1e-3 – Albert Renshaw – 2017-02-15T03:31:10.217

6

Jelly, 31 bytes

*3×
²+’*3<çị⁾* 
25µNr÷21µ²ç@þUY

Try it online!

or 35 bytes with a , rather than * fill: change middle line to ²+’*3<ç×9829Ọ»⁶.

          ♥♥♥♥♥♥♥♥♥♥           ♥♥♥♥♥♥♥♥♥♥          
        ♥♥♥♥♥♥♥♥♥♥♥♥♥♥       ♥♥♥♥♥♥♥♥♥♥♥♥♥♥        
      ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥      
     ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥     
     ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥     
    ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥    
   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   
   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   
   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   
   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   
    ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥    
    ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥    
     ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥     
     ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥     
      ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥      
      ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥      
       ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥       
        ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥        
        ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥        
         ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥         
          ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥          
           ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥           
            ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥            
             ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥             
              ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥              
               ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥               
                 ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥                 
                  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥                  
                   ♥♥♥♥♥♥♥♥♥♥♥♥♥                   
                     ♥♥♥♥♥♥♥♥♥                     
                      ♥♥♥♥♥♥♥                      
                        ♥♥♥                        
                         ♥                         

How?

Implements: equation over a 51 by 51 line feed separated grid of characters.

*3× - Link 1: y, xSquared
*3  - cube y
  × - multiply the result by xSquared

²+’*3<çị⁾*  - Link 2: y, xSquared
²           - square y
 +          - add xSquared to the result
  ’         - subtract one
   *3       - cube the result
     <      - less than? (1 if True, 0 if False)
      ç     -     the result of the last link (1) as a dyad: f(y, xSquared)
       ị    - index into (1-based):
        ⁾*  - the string "* " (there is a trailing space on this line)

       ×9829Ọ»⁶ - alternative ending of link 2
       ×9829    - multiply (vectorises) by 9829
            Ọ   - cast to character (vectorises) (9829 is the ♥, 0 is the null-byte)
             »  - maximum (vectorises) of that and:
              ⁶ -     space character (ordinal of space is 32, greater than the null-byte, less than ♥)

25µNr÷21µ²ç@þUY - Main link: no arguments
25              - 25
  µ             - monadic chain separation call that i
   N            - negate i
    r           - inclusive range(negated i, i) -> [-25, -24, ..., 24, 25]
     ÷21        - divide by 21 (vectorises) -> [-1.1904761904761905, -1.1428571428571428, ..., 1.1428571428571428, 1.1904761904761905]
        µ       - monadic chain separation call that r
         ²      - square r (vectorises) (make the xSquared values, left to right)
             U  - upend r (make the y values, top to bottom)
            þ   - outer product using:
          ç@    -     last link (2) as a dyad with reversed arguments: f(y, xSquared)
              Y - join with line feeds
                - implicit print

Jonathan Allan

Posted 2017-02-13T13:10:25.730

Reputation: 67 804

5

JavaScript (ES6), 151 147 bytes

document.write`<canvas id=c>`;for(i=0;x=2-i/24,i<97;i++)for(j=0;y=2-j/24,z=x*x+y*y-1,j<97;j++)z*z*z-x*x*y*y*y<0&&c.getContext`2d`.fillRect(i,j,1,1)

Edit: Saved 4 bytes thanks to @user2428118. ES7 version for 143 bytes:

document.write`<canvas id=c>`;for(i=0;i<97;i++)for(x=2-i/24,j=0;j<97;j++)x*x*(y=2-j/24)**3-(x*x+y*y-1)**3>0&&c.getContext`2d`.fillRect(i,j,1,1)

Neil

Posted 2017-02-13T13:10:25.730

Reputation: 95 035

how about y**3 instead of y*y*y ? – svarog – 2017-02-14T07:14:47.027

1@svarog Thus my note "Would be slightly shorter in ES7"... – Neil – 2017-02-14T08:36:16.333

well, it works on chromium 55, so why not add an es7 version ? – svarog – 2017-02-14T09:14:59.123

1@svarog Because I don't have chromium 55 handy... – Neil – 2017-02-14T15:20:44.427

You could always use Babel... – ThisSuitIsBlackNot – 2017-02-14T18:46:36.763

You could probably save some bytes by using template strings: document.write`<canvas id=c>`; and c.getContext`2d` seem possible. – user2428118 – 2017-02-15T14:21:19.673

1@ThisSuitIsBlackNot It complained about undeclared variables when I tried. – Neil – 2017-02-15T18:03:00.280

@svarog Finally got around to updating to Firefox 52... only seems to save 4 bytes though. – Neil – 2017-03-20T10:29:42.223

4

BBC BASIC, 80

Will finish golfing tomorrow.

Download interpreter at http://www.bbcbasic.co.uk/bbcwin/bbcwin.html

ORIGIN99,99F.u=-56TO56x=u/50b=x^2^.33/2r=(b^2-x^2+1)^.5*50L.u,b*50-r,u,r+b*50N.

Draws a filled heart using the first equation, which we rearrange and take the cube root of (there are 3 cube roots of a real number, one real and 2 complex but we only interested in the real root here.) We then rearrange again to get a quadratic in y

x^2+y^2-1=(x^0.66)y

y^2-(x^0.66)y+x^2-1=0

Using the standard quadratic formula for expressions of the type ay^2+by+c=0, and taking advantage of the fact that a=1 we get

y = -b/2 +/- sqrt((b/2)^2-c)

y = -b/2 +/- sqrt((b/2)^2-x^2+1)

where -b/2 = (x^0.66)/2 (represented by b in the program.)

We simply scan through the values of x from left to right, drawing a vertical line between each pair of valid values for y to build up a solid shape.

ORIGIN99,99F.u=-56TO56x=u/50b=x^2^.33/2r=(b^2-x^2+1)^.5*50L.u,b*50-r,u,r+b*50N.

ungolfed

ORIGIN99,99
FORu=-56TO56
  x=u/50
  b=x^2^.33/2
  r=(b^2-x^2+1)^.5*50
  LINEu,b*50+r,u,b*50-r
NEXT

Level River St

Posted 2017-02-13T13:10:25.730

Reputation: 22 049

4

Ruby, 80 bytes

Show Ruby some love.

-2.step(2,0.2){|y|-2.step(2,0.1){|x|$><<'. O'[(y*y-1+x*=x)**3+x*y**3<=>0]};puts}

Output:

         OOOOO     OOOOO             
      .OOOOOOOOO.OOOOOOOOO.          
     OOOOOOOOOOOOOOOOOOOOOOO         
     OOOOOOOOOOOOOOOOOOOOOOO         
     OOOOOOOOOOOOOOOOOOOOOOO         
      OOOOOOOOOOOOOOOOOOOOO          
      .OOOOOOOOOOOOOOOOOOO.          
        OOOOOOOOOOOOOOOOO            
         OOOOOOOOOOOOOOO             
           OOOOOOOOOOO               
              OOOOO                  
                .                    

with some empty lines above and below

G B

Posted 2017-02-13T13:10:25.730

Reputation: 11 099

2

TI-84 Basic, 40 38 bytes

Similar to @12Me21's answer & output, but for the TI-83/84 series instead.

While 1:2rand-1→A:2rand-1:If (A²+Ans²-1)³>A²Ans³:Pt-On(A,Ans:End

Timtech

Posted 2017-02-13T13:10:25.730

Reputation: 12 038

Is using Ans actually smaller here? I thought Ans was 2 bytes. – 12Me21 – 2017-02-13T16:48:44.287

@12Me21 No, it's the same size, and faster too. (For TI-83/84 at least, I don't know about TI-80). – Timtech – 2017-02-13T16:52:38.653

2

Processing.js: 123 119 bytes

ungolfed:

t = 0; 

void setup() {
    size(99, 300); 
} 

void draw() {
    point(59+99*sin(t)*cos(t)*log(t),350-400*sqrt(cos(t))*pow(t,0.3));
    t+=0.01;
}

golfed:

t=0;void setup(){size(99,300);}void draw(){point(59+99*sin(t)*cos(t)*log(t),350-400*sqrt(cos(t))*pow(t,0.3));t+=0.01;}

this one is quite cheaty as it plots #2 from 0 to infinity instead of from -1 to 1 as shown in the picture to save on the two abs(t). But it's technically correct as there are more than 100 points.


130 bytes "correctier" one

t=-1;void setup(){size(99,300);}void draw(){point(59+99*sin(t)*cos(t)*log(abs(t)),350-400*sqrt(cos(t))*pow(abs(t),0.3));t+=0.01;}

try it online

note : there's probably a way to get 100 points on the default 100x100 canvas and shave the setup off.

satibel

Posted 2017-02-13T13:10:25.730

Reputation: 221

None of your snippets do anything for me on my local version of Processing (except for the second one which just draws 1 point) – user41805 – 2017-02-13T15:34:40.090

have you tried on sketchpad? ("try it online") you need to click "render sketch" – satibel – 2017-02-13T15:35:50.030

But I think that would be called "Processing.JS" instead. For the snippet to work for me, you have to use float instead of int – user41805 – 2017-02-13T15:37:16.950

oops, forgot the .js, and thanks to that I saved 4 bytes by removing the useless int. – satibel – 2017-02-13T15:41:21.260

1

BBC BASIC (BBC Micro) (126 bytes)

This is a variation of Level River Street's answer, but for the original BBC Micro's iteration of BBC BASIC.

You can copy and paste either of the following into JSBeeb's new paste functionality at https://bbc.godbolt.org/ (A JavaScript powered BBC Micro emulator), once it has pasted, press Enter inside the 'screen' to show a new prompt, then type RUN, then press Enter to run either version.

golfed. (126 bytes)

1MO.1:V.29,64;64;:MOVE-57,20:GC.0,1:F.U=-56TO56:X=U/50:IFX<>0TH.B=X^2^.33/2
2R=(B^2-X^2+1)^.5*50:DRAWU,B*50+R:DRAW U,B*50-R:N.

ungolfed. (176 bytes)

1 MODE 1
2 VDU 29,64;64;
3 MOVE -57,20
4 GCOL 0,1
5 FOR U = -56 TO 56
6 X = U/50
7 IF X <> 0 THEN B = X^2^.33/2
8 R = (B^2-X^2+1)^.5*50
9 DRAW U,B*50+R
10 DRAW U,B*50-R
11 NEXT

Line 7 requires a check for X, to prevent a "Log range" error when X becomes 0 half way through the loop. Other than this, it's pretty much the same. It's a lot slower to draw on a real machine, which JSBeeb emulates pretty well.

sassquad

Posted 2017-02-13T13:10:25.730

Reputation: 11