In the morning of her first day at school, Mary (Mckenna Grace
) is in a foul mood because she doesn't want to go. She wants Frank (Chris Evans
) to continue homeschooling her, but he says he's taught her everything he knows, and she needs the experience. As soon as he sees the reluctant, sulking Mary off to school, he's confronted by Roberta (Octavia Spencer
), who's his landlady and friend, and cares deeply for Mary. She tells him to get in his car and bring Mary back before it's too late, afraid that she will be taken away once everyone realizes she's a child prodigy. Frank tries to calm her down, saying Mary needs friends and social skills. Roberta isn't convinced, but there's nothing she can do, so she lets go.
At school, Mary is shown bored out of her mind as Bonnie (Jenny Slate
), her teacher, goes over first grade math problems with the rest of the class. Mary eventually speaks up, making it known that the lack of challenge is beyond her ability to bear. Bonnie warns her for speaking out of turn, and starts asking her increasingly difficult arithmetic problems to make a point. To her surprise, Mary answers them all. After recess, the Principal requests a walk-in observation of Bonnie's class. As soon as she introduces herself to the children, Mary demands to know if she's "the boss", and upon confirmation, demands that she call Frank right away and tell him to get her out of there. When Frank comes to pick Mary up, Bonnie catches up to him on the front yard and tells him she thinks Mary might be a gifted child. Frank chalks it off to some simple algorithm he's taught her and walks away before Bonnie can discuss the matter with him any further.
Bonnie then does her own research, and finds out that Mary's mom Diane was a Math genius, also, working on one of the Millennium Prize problems when she apparently took her own life and was survived by his brother Frank. She then confronts Frank at the bar she knows he hangs out on Friday nights, and learns the back story. Diane, her sister, appeared at her doorstep out of the blue one night with Mary, who was just a baby at the time. She said she needed to talk to him but Frank, already late for a date, told her they'd talk when he got back. When he got back, Diane had committed suicide in the bathroom, and Mary was in his living room. He's been raising her since then.
On the school bus one day, Mary witnesses bullying and stands up for the victim, breaking the nose of the bully who's five years her senior. Frank is called to the Principal's office, where she tells him she can get a full ride for Mary at a nearby school for the gifted. Frank refuses the offer on the grounds that she wants Mary to have a normal childhood. The Principal then reaches out to Evelyn (Lindsay Duncan
), Frank's mother and Mary's grandmother.
Evelyn shows up at Frank's door soon after, and meets Mary for the first time. She's a rich, bossy Englishwoman whose ideas of life and ambition Frank clearly disagrees with. She criticizes Frank's lifestyle choices and demands to take Mary away with her to Boston. When Frank disagrees, she takes him to court.
In the court hearings and over that period of time, we find out more about the friction between Evelyn and Frank. Evelyn is disappointed in her dead daughter for being too weak to complete the Millennium Prize problem, disappointed in Frank for having quit his professorship at Boston University, and resentful of her late husband for disrupting her successful career. She's also having problems with her current husband, and they are separated. Frank doesn't openly accuse of her anything, but insists that Evelyn will deny Mary the normalcy a child needs in her life, and that him being a freelance boat repairman is perfectly fine. Roberta stands by Frank throughout the ordeal, and his lawyer (Glenn Plummer
) does a good job defending him. In the end, though, Evelyn wants to settle by putting Mary in foster care in close proximity of Frank's house and making her go to the school for gifted children.
Crushed under the guilt of not having stayed with Diane the night of her death, and his insecurity over his capability for raising Mary, he yields. Mary is absolutely furious, however, and refuses to see Frank after he's left her with the foster family despite her relentless begging and tears. Frank is desolate, but is determined to do what everyone seems to think is best for Mary, when he finds out thanks to Bonnie that the foster family has put Mary's beloved one-eyed cat up for adoption.
He rushes to the animal shelter and rescues Mary's car and two other last minute before they are put down. He finds out from the front desk at the shelter that the cat was brought there due to allergy issues. Knowing it's Evelyn who's allergic to cats, he makes a quick stop at his place and then rushes to the foster family's home to confront Evelyn. As he suspected, she's in the guest house with Mary and two tutors. Upon seeing him, Mary runs away. Frank follows suit after throwing a file on the desk and tells Evelyn she must see it. Evelyn tries to go after them but Roberta physically blocks her way and stops her. Frank manages to catch up to Mary and ask for forgiveness. Mary stops fighting and hugs him, and her spirits get even more elevated as she finds out her cat is at Frank's place safe and sound.
When Mary and Frank return to the guesthouse, Roberta takes Mary to the car, and Frank orders the tutors out. We find that it's the finished proof for the Millennium Prize problem Diane had been working on. Evelyn says she doesn't believe it because she would have shared it with the world. Frank tells her that Diane gave him clear instructions to wait to publish it until after their mother's death. He tells her that she can go ahead and publish it, and leave Mary alone. Since she asks, he tells Evelyn that if she refuses, he'll take the folder away and wait to publish it until after Evelyn dies. Evelyn is shocked and in tears, but she takes the deal.
At the end, Mary is shown attending classes at the university in the mornings, and the elementary school in the afternoons. Bonnie and Frank smile at each other with affection.