# Optimizing Jetpack Compose with a Fast Cube Root Approximation

DevFeed: [Optimizing Jetpack Compose with a Fast Cube Root Approximation](<https://devfeed.tech/articles/going-old-school-25598.md>)

Original publisher: [Read original article](<https://www.romainguy.dev/posts/2024/going-old-school/>)

Author: Romain Guy

Published: 2024-01-25T00:00:00Z

Content type: tutorial

Language: en

Sources: [Posts on Romain Guy](<https://devfeed.tech/sources/posts-on-romain-guy.md>)

Topics: [Compose](<https://devfeed.tech/topics/compose.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Optimization](<https://devfeed.tech/topics/optimization.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [implementation](<https://devfeed.tech/topics/implementation.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [android](<https://devfeed.tech/tags/android.md>), [compose](<https://devfeed.tech/tags/compose.md>), [developer](<https://devfeed.tech/tags/developer.md>), [graphics](<https://devfeed.tech/tags/graphics.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [math](<https://devfeed.tech/tags/math.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [performance](<https://devfeed.tech/tags/performance.md>), [snippet](<https://devfeed.tech/tags/snippet.md>)

## AI overview

The article explains how a fast cube root approximation can optimize Jetpack Compose. It applies a float-bit estimation and two Newton-Raphson refinement steps, improving color interpolation by 8% and 2D cubic-easing animations by 17%.

## Source excerpt

While looking for optimization opportunities in various parts of Jetpack Compose, I recently discovered that calling the cube root function was taking a non-neligible amount of times in two areas of the Toolkit: when evaluating cubic Bézier easing curves and when interpolating colors through the OkLab color space. Working on graphics projects taught me that approximations can often be powerful optimization tools, so I decided to come up with an approximation of cbrt()1: