[R] computer algebra in R

Konrad konr@d_kr@emer @end|ng |rom y@hoo@de
Tue Nov 28 11:03:36 CET 2023


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



More information about the R-help mailing list