Skip to content

Commit

Permalink
Linearize input by using GeoGebra's jacobiPrepare method
Browse files Browse the repository at this point in the history
  • Loading branch information
kovzol committed Oct 28, 2019
1 parent d295203 commit 8aef11e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/realgeom/Compute.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,16 @@ public static String euclideanSolverExplore(String lhs, String rhs, String polys
} // in varsubst we have something like a1->0, a2->0, b1->1, b2->0
// String polysSubst = "Print[Quiet[{" + polys + "}/.{" + varsubst + "} // InputForm]]"; // Mathematica syntax
// appendResponse("LOG: polysSubst=" + polysSubst, Log.VERBOSE);
appendResponse("LOG: before substitution, polys=" + polys,Log.VERBOSE);
String polys2 = GiacCAS.execute("subst([" + polys + "],[" + varsubst + "])");
String ggInit = "caseval(\"init geogebra\")";
String jpDef = "jacobiPrepare(polys,excludevars):=begin local ii, degrees, pos, vars, linvar; vars:=lvar(polys); ii:=0; while (ii<size(polys)-1) do degrees:=degree(polys[ii],vars); if (sum(degrees)=1) begin pos:=find(1,degrees); linvar:=vars[pos[0]]; if (!is_element(linvar,excludevars)) begin substval:=op(solve(polys[ii]=0,linvar)[0])[1]; polys:=remove(0,expand(subs(polys,[linvar],[substval]))); print(polys); ii:=-1; end; end; ii:=ii+1; od; return polys; end";
polys2 = polys2.substring(1,polys2.length() - 1); // removing { and } in Mathematica (or [ and ] in Giac)
appendResponse("LOG: before linearization, polys=" + polys2,Log.VERBOSE);
String linCode = "[[" + ggInit + "],[" + jpDef + "],jacobiPrepare([" + polys2 + "],[" + "])][2]";
appendResponse("LOG: linearization code=" + linCode,Log.VERBOSE);
polys2 = GiacCAS.execute(linCode);
appendResponse("LOG: after linearization, polys=" + polys2,Log.VERBOSE);
// String polys2 = ExternalCAS.executeMathematica(polysSubst, timelimit); // Mathematica call
polys2 = polys2.substring(1,polys2.length() - 1); // removing { and } in Mathematica (or [ and ] in Giac)

Expand All @@ -318,5 +327,5 @@ public static String euclideanSolverExplore(String lhs, String rhs, String polys

return response;
}

}

0 comments on commit 8aef11e

Please sign in to comment.