<jupyter_start><jupyter_text>Wiggle your big trunk[<NAME>](https://en.wikipedia.org/wiki/John_von_Neumann) once famously said:  With four parameters I can fit an elephant, and with five I can make him wiggle his trunk.His quote was thoroughly investigated in the [groudbreaking work of Mayer et al](https://publications.mpi-cbg.de/Mayer_2010_4314.pdf). As a first exercise, base yourself on their paper to plot the elephant shown in their figure (b).<jupyter_code>import matplotlib.pyplot as plt
import numpy as np

# Set up the function for obtaining the x, y coordinates of the elephant drawing:
def elephant(angles, parameters):
    """
    Return the x and y coordinates of an elephant drawing.
    
    Args:
        angles (numpy.ndarray): Array of the angle mesh for which the elephant coordinates should be determined.
        parameters (List): List of four complex parameters
        
    Returns:
        x, y: Coordinates of the elephant drawing.
    
    """
    
    x = np.zeros(angles.shape)
    y = np.zeros(angles.shape)
    
    A_x = [0, 0, parameters[2].real, 0, parameters[3].real]
    B_x = [parameters[0].real, parameters[1].real, 0, 0, 0]
    
    A_y = [parameters[3].imag, 0, 0, 0, 0]
    B_y = [parameters[0].imag, parameters[1].imag, parameters[2].imag, 0, 0]
    
    for k, ax, bx, ay, by in zip(range(1, 6), A_x, B_x, A_y, B_y):
        y -= ax * np.cos(k * angles) + bx * np.sin(k * angles)
        x += ay * np.cos(k * angles) + by * np.sin(k * angles)
        
    return x, y
parameters = [50-30j, 18+8j, 12-10j, -14-60j]
# Based on the parameters of the paper of Mayer et al. and the elephant function, plot the elephant with matplotlib<jupyter_output><empty_output><jupyter_text>--- Wiggling timeOf course, now we want to make the elephant's trunk wiggle. To do this, we will write a function that plots the body and trunk of the elephant separately. First, we have to figure out what part of the angle range corresponds to the trunk and the body. One way to figure this out interactively is using a `FloatRangeSlider`. Start by setting up a function for plotting the elephant coordinates within a certain angle range:<jupyter_code>def plot_elephant(angle_range, parameters):
    """
    Plot the elephant coordinates over the range defined by times, based on the parameters.
    
    Args:
        angle_range (tuple): Tuple of the minimum and maximum angles for which the elephant coordinates should be determined.
        parameters (List): List of complex parameters
    
    """
    raise NotImplementedError # Be sure to remove this when you've implemented your code<jupyter_output><empty_output><jupyter_text>Now set up a `FloatRangeSlider` that allows you to explore the effect of drawing the coordinates of the elephant over a certain range.<jupyter_code># Type your code here<jupyter_output><empty_output><jupyter_text>Base yourself on the interactive tool you've just designed to figure out what angle ranges you have to consider to plot the body and the trunk. Finally, set up a function that plots the body and trunk separately, and changes the position of the trunk a little based on the wiggle parameter. Once the function is set up, you can use the interact tool to plot the elephant and allow for a range of values for the wiggle parameter to wiggle the trunk.<jupyter_code>def wiggle_trunk(parameters, wiggle_parameter):
    """
    Plot the elephant coordinates over the range defined by times, based on the parameters.
    
    Args:
        angle_range (tuple): Tuple of the minimum and maximum angles for which the elephant coordinates should be determined.
        parameters (List): List of complex parameters
    
    """
    raise NotImplementedError # Be sure to remove this when you've implemented your code

    # Draw the body of the elephant

    # Obtain the trunk x,y coordinates

    # Adjust the position of the trunk a little

    # Plot the wiggled trunk
# Use the interact function in combination with the wiggle_trunk function and a suitable widget to let the trunk wiggling begin<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0702226572057744, 'fraction_numerical': 0.011010521164668462, 'mean_word_length': 3.6454545454545455, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '253497', 'license': 'MIT', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1122, 'n_words': 534, 'path': 'extra/elephant.ipynb', 'repo_name': 'mbercx/jlab-workshop', 'size': '4097'}