From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 0EVyDp65g2Mh9QAAbAwnHQ (envelope-from ) for ; Sun, 27 Nov 2022 20:25:18 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id EFN1Dp65g2N2gAAAauVa8A (envelope-from ) for ; Sun, 27 Nov 2022 20:25:18 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DA3412C7A1 for ; Sun, 27 Nov 2022 20:25:17 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ozNGG-0000iE-A3; Sun, 27 Nov 2022 14:24:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozNGD-0000i1-OZ for emacs-orgmode@gnu.org; Sun, 27 Nov 2022 14:24:17 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ozNGB-0001L4-FH for emacs-orgmode@gnu.org; Sun, 27 Nov 2022 14:24:17 -0500 Received: by mail-wm1-x32f.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so10092001wma.1 for ; Sun, 27 Nov 2022 11:24:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-language:to:subject:from:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=PgzPnTyjHCWfukRpQnWI+neMpyBapTifTO3BL7RO8Z8=; b=WpoqLYHzAu94zwKDJRMdhfkZ7BBrhucbaAZJl1tZqeDFy+sH8CLLnISl56Wnwbigxv c0HgDiCz8Fzw0fvumlNSC9avODtIwnCakwWSCihAxry91XjRUcRyr7FJaeyNXXmhIrb3 0n4q/Wyn+th2i3GSi4wfDoTgs4+dMyKonXfWLBYSFUeyN9iVJsKWmvRGdK8Te+GYzfOn YtxgHjSoifvas0BflBw9s/Ihl7LjUAtuV76JYm7B5v81s4HGyfYx1MkYQ1YmHYAUomNf 7ctKQObcY3Uj+pSGFMm2rfSc91W7yQ+VbLZNnhrBOm7bfcQndITaRjSMqG0ajhqT46Xu MkRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-language:to:subject:from:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PgzPnTyjHCWfukRpQnWI+neMpyBapTifTO3BL7RO8Z8=; b=nFC8bQgc12VZoh0/bi4Slqpo9msltmm9QvPDsmaqDZb4Fqkrb8PPGp4vmjlrza8WV5 yR9sxEFvb+nRRVF9qbEAt7xAGQDKtw5ki/N4DLX5X7wWQa4eXaJJz/bt8t07j9DbFvGH sU5QHGVZnAq3dtW7sj92UfKnF/OBqM1D+31tOOL2EbC2+3c1o6szTmBlbbBWxqGn3hEP shepBjY8yg1vEbpd0m22/VNrsudCKVWvpfbDmoL1Gdi0fXJgSai0bMycFPLHtsmele8s bOM8Twq8cgbSQXlz4+jVrTI7/+5iezqEpu3aAcikQ7/6PUR0OEF94mQ2V/WTI0sTle5g A+Hg== X-Gm-Message-State: ANoB5plKXPgD9CSO2WcQpt1gDzkmWfA/mpMnc8jhNv7RQklZMrpCI9ph Q2sGdIcnkdh2g0Dap8Hy2B/Hwsakao/f1g== X-Google-Smtp-Source: AA0mqf6OLn4prh8RXBPCXl8c8LOV2eIS6bYZ1RrgvxyY2nFPlEPgcJqgyfPbR6vLvjjK2AbChvP1Pg== X-Received: by 2002:a7b:ce89:0:b0:3c6:c986:f2b9 with SMTP id q9-20020a7bce89000000b003c6c986f2b9mr34821616wmj.53.1669577053554; Sun, 27 Nov 2022 11:24:13 -0800 (PST) Received: from [192.168.0.97] (static-236-73-225-77.ipcom.comunitel.net. [77.225.73.236]) by smtp.gmail.com with ESMTPSA id bg3-20020a05600c3c8300b003c71358a42dsm22176184wmb.18.2022.11.27.11.24.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 27 Nov 2022 11:24:13 -0800 (PST) Content-Type: multipart/alternative; boundary="------------2YAVDevOu8BUQR35CjmmmBdd" Message-ID: <2ff2b255-029d-c0f4-6102-0e4482b53b63@gmail.com> Date: Sun, 27 Nov 2022 20:19:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 From: Ypo Subject: To convert and simplify units in tables (was:LIterate programming with calc (help)) To: Org-mode Content-Language: en-GB Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=ypuntot@gmail.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1669577118; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=PgzPnTyjHCWfukRpQnWI+neMpyBapTifTO3BL7RO8Z8=; b=A0qIf/ajg5OCyMK2z6C6+TmDaIP0lAni/8HW39MwsNZNFAjVZZuAH29CCSgdr7gdgFIJgn 22CHVs4oo1SdqbLE+y/N1UMTiwZU5l5nz3Xe1ucaA0AXlfBlVHYeYo8HER1ND6xxlGO9sg /BBYRgY8cegYJdiXoquUuATNoFvfoa8dHZpG0NdMUlSpQAtHuH7lWVBPpp+FJ3voOACaFT XbrSa64yBS94KQZKxBEzBYysgrHgyiBZ9uBQgd02cJ+uiJRDxH0xrvlPiWKKXhEGEZLODt 6H9KSmrzRx4Asp7BbbEMoGpR97/dWTrIU0E7S9JNrvDof6UEzWGicgfifM3Pkw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1669577118; a=rsa-sha256; cv=none; b=FmCofPe84TEDhp9VolcqTmqhIigquZFZbkW5T4eNsBjVwIyXe5Adh4+e94liH3CoALoy+7 XhFWQ8lfwJ0vHVGnbEMEc2IXEVts+GyEkkVUpv5Bho8V7qXgwAQKXQcnllpRPY5CQkUExI PRBFCn4XnUoPt9jHF0wzgPxIEectZtfAIgVbLtxxNog1ymhzZO1tSJOdSjhnGMXtyjJBOn y2OC5EyKgqEadaVZ8GC7YBt5RM2Z4otiZ3Niv97ujAu/sdSd4yDBop47o3fSg1k1czCAYo yB4lmNyb25JsYT2QHm5zzzmvUekdAxmM0HVbGhzRPeVnvDvl+VUmqjrLRDGJLA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WpoqLYHz; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -9.76 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WpoqLYHz; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: DA3412C7A1 X-Spam-Score: -9.76 X-Migadu-Scanner: scn0.migadu.com X-TUID: rmEJhfgu6SUV This is a multi-part message in MIME format. --------------2YAVDevOu8BUQR35CjmmmBdd Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi I have found an alternative solution to this problem: > Is it possible to express in a calc block some basic operations with > variables and non-predefined units? > > > For example, if you wanted to build a code block that calculates how > much money costs > > a land with an Area of 300x300 m^2 at a price of 1 $/m^2. > > > Would it be something like this? > > #+begin_src calc >   a = 300 m >   b = 300 m >   Area = a*b >   cost = 1 ($/m^2) >   A*c > > #+end_src > The alternative way I am trying is using an org-table. It is not literate programming, but it is a spreadsheet with units ;D | $ | a = 300 m        | | $ | b = 300 m        | | _ | Area             | |   | 90000 m^2        | | $ | cost = 1 USD/m^2 | | _ | Payment          | |   | 90000 USD        | #+TBLFM: $Area=$a*$b::$Payment=$Area*$cost (Below "Area" cell it is the result of a*b, and below "Payment" cell it is the result of Area*cost) Now, in a more practical case, I have some problems with units: | $ | E = 2141404.05 kg/cm^2          | | $ | s_lim = 275  N/mm^2              | | $ | s_lim = 2800  kg/cm^2            | | $ | W = 10000 kg                     | | $ | l = 65  cm                       | | $ | I = 25166  cm^4                  | | $ | Z = 1680  cm^3                   | | _ | s                                | |   | 386.90476 kg cm / cm^3           | | _ | cs                               | |   | 7.2369231 kg cm^3 / (cm^2 kg cm) | #+TBLFM: $s=$W*$l/$Z::$cs=$s_lim/$s Below "cs" cell it appears 7.2... and this should be an adimensional number (no units). Is it possible to simplify those units? I have tried with: | $ | E = 2141404.05  kg/cm^2 | | $ | s_lim = 275  N/mm^2     | | $ | s_lim = 2800  kg/cm^2   | | $ | W = 10000 kg            | | $ | l = 65  cm              | | $ | I = 25166  cm^4         | | $ | Z = 1680  cm^3          | | _ | s                       | |   | 386.90476 kg / cm^2     | | _ | cs                      | |   | #ERROR                  | #+TBLFM: $s=uconvert($W*$l/$Z,kg / cm^2)::$cs=uconvert($s_lim/$s, ) where uconvert is defined as: (defmath uconvert (v u)   "Convert value V to compatible unit U."   (math-convert-units v u)) But no luck, "cs" result is an ERROR. Is it feasible to get a value for "cs" with no units? Best regards --------------2YAVDevOu8BUQR35CjmmmBdd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi

I have found an alternative solution to this problem:

Is it possible to express in a calc block some basic operations with variables and non-predefined units?


For example, if you wanted to build a code block that calculates how much money costs

a land with an Area of 300x300 m^2 at a price of 1 $/m^2.


Would it be something like this?

#+begin_src calc
  a = 300 m
  b = 300 m
  Area = a*b
  cost = 1 ($/m^2)
  A*c

#+end_src


The alternative way I am trying is using an org-table. It is not literate programming, but it is a spreadsheet with units ;D

| $ | a = 300 m        |
| $ | b = 300 m        |
| _ | Area             |
|   | 90000 m^2        |
| $ | cost = 1 USD/m^2 |
| _ | Payment          |
|   | 90000 USD        |
#+TBLFM: $Area=$a*$b::$Payment=$Area*$cost

(Below "Area" cell it is the result of a*b, and below "Payment" cell it is the result of Area*cost)


Now, in a more practical case, I have some problems with units:

| $ | E = 2141404.05  kg/cm^2          |
| $ | s_lim = 275  N/mm^2              |
| $ | s_lim = 2800  kg/cm^2            |
| $ | W = 10000 kg                     |
| $ | l = 65  cm                       |
| $ | I = 25166  cm^4                  |
| $ | Z = 1680  cm^3                   |
| _ | s                                |
|   | 386.90476 kg cm / cm^3           |
| _ | cs                               |
|   | 7.2369231 kg cm^3 / (cm^2 kg cm) |
#+TBLFM: $s=$W*$l/$Z::$cs=$s_lim/$s

Below "cs" cell it appears 7.2... and this should be an adimensional number (no units). Is it possible to simplify those units?

I have tried with:

| $ | E = 2141404.05  kg/cm^2 |
| $ | s_lim = 275  N/mm^2     |
| $ | s_lim = 2800  kg/cm^2   |
| $ | W = 10000 kg            |
| $ | l = 65  cm              |
| $ | I = 25166  cm^4         |
| $ | Z = 1680  cm^3          |
| _ | s                       |
|   | 386.90476 kg / cm^2     |
| _ | cs                      |
|   | #ERROR                  |
#+TBLFM: $s=uconvert($W*$l/$Z,kg / cm^2)::$cs=uconvert($s_lim/$s, )

where uconvert is defined as:

(defmath uconvert (v u)
  "Convert value V to compatible unit U."
  (math-convert-units v u))


But no luck, "cs" result is an ERROR. Is it feasible to get a value for "cs" with no units?


Best regards


--------------2YAVDevOu8BUQR35CjmmmBdd--