[R] computer algebra in R

Søren Højsgaard @orenh @end|ng |rom m@th@@@u@dk
Tue Nov 28 19:37:03 CET 2023


Just wanted to mention that the caracas package *may* be better at solving this problem
Best
Søren

-----Original Message-----
From: Konrad via R-help <r-help using r-project.org>
Reply-To: Konrad <konrad_kraemer using yahoo.de>
To: R-help using r-project.org
Subject: [R] computer algebra in R
Date: Tue, 28 Nov 2023 11:03:36 +0100

Dear all,

I'm currently working on converting mathematica code 
(https://github.com/ASDSE/thermosimfit/blob/master/Packages/thermoHD-Comp/thermoCacheHD-1Comp.m) 
to R. The code is related to solve algebraic systems.

> eqthermo = {h0 == h + hd + hga, d0 == d + hd, ga0 == ga + hga, kga ==
>      hga / (h * ga), kd == hd / (h * d)};
> 
> (* IDA HD*)
> sthdIDAcacheHD[fkd_, fkga_, fh0_, fd0_] :=  sthdIDAcacheHD[fkd, fkga, 
> fh0, fd0] =
>                Module[{eliHD, solvHD},
>                 eliHD =
>              Eliminate[
>               eqthermo /. {d0 -> fd0, h0 -> fh0, kd -> fkd, kga -> 
> fkga}, {h, d, hga, ga}];
>                 solvHD = hd /. NSolve[eliHD, hd];
>                 Return[solvHD];
>                 ];

  I tried to use the Ryacas package. However, I'm struggling with the 
Elimination step. Within this step a system of equations:

0.3==h+hd+hga,0.4==d+hd,ga0==ga+hga,0.2==hga/(ga h),0.1==hd/(d h) is 
transformed to: -12.+1040. hd+2575. hd^2-250. hd^3==ga0 hd (-200.+500. hd).

My question is whether someone has experience with yacas and can tell me 
how to do this step in R. Beyond that, I would be grateful for every 
hint how to transfer this into R.

All the best,

Konrad

______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

-- 
Søren Højsgaard
Head of Department of Mathematical Sciences
Aalborg University, Denmark.
Chair of the Danish Statistical Society



More information about the R-help mailing list