---
title: "log(): typeshade/core/ir의 IR 빌더 함수, TypeShade 컴파일러 API"
description: "log, typeshade/core/ir의 IR 빌더 함수입니다. log(x): 자연로그이며, 성분별로 계산합니다. 수학, 벡터, 텍스처 연산을 만드는 IR 빌더 함수입니다. 각 함수는 IR 노드를 반환합니다."
url: https://typeshade.dev/ko/api/log/
language: ko
---

# `log()`

함수, 내장 함수 분류

`log(x)`: 자연로그이며, 성분별로 계산합니다.

`import { log } from 'typeshade/core/ir'`

이 export는 IR 노드를 반환합니다. `"use typeshade"` 파일에서는 내장 함수 자체를 부릅니다: [`log()`](https://typeshade.dev/ko/reference/functions/log/)

설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.

## 구문

```ts
const log: <K extends FloatKey>(x: ReadonlyNode<K>) => Node<K>
```

## 매개변수

**`x` `ReadonlyNode<K>`**

## 반환값

`Node<K>`

## 설명

[`log2`](https://typeshade.dev/ko/api/log2/)는 밑이 2인 형태입니다. 명세상 `x <= 0`에서는 값이 정의되지 않으므로, 인자가 0에 이를 수 있다면 [`max`](https://typeshade.dev/ko/api/max/)로 인자에 하한을 둡니다.

## 예제

### 예제

```ts
import { fn, log, max, f32, f32T } from 'typeshade/core/ir'

const decayRate = fn('decayRate', { x: f32T }, ({ x }) => log(max(x, f32(1e-6))))
```

## 대상별 지원

| 대상 | 지원 | 비고 |
| --- | --- | --- |
| WGSL (WebGPU) | 지원 | `log(x)`로 생성합니다. |
| GLSL ES 3.00 (WebGL2) | 지원 | `log(x)`로 생성합니다. |
| CPU 오라클 | 지원 | 오라클이 `f64`로 계산합니다. |

## 관련 가이드

- [배포용 생성](https://typeshade.dev/ko/guide/internals/production-emit/)

## 함께 보기

- [`log()`](https://typeshade.dev/ko/reference/functions/log/)
- [`log2`](https://typeshade.dev/ko/api/log2/)
- [`max`](https://typeshade.dev/ko/api/max/)

## 소스

[`src/core/ir/node.ts`, 1188행](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L1188), 커밋 af54ddad5 기준
