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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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.