0

i connected python with mathematica and called the solve method from mathematica in python (with WolframclientForPython). The result is the same as in mathematica but in python I only get classes that are cryptic to read.

If i print a result in python it looks like this:

Rule[Globalx121101, Times[-1, Power[Plus[Times[-1, Power[Globalx121111, 2]], Times[-1, Power[Global`x121121, 2]]], Rational[1, 2]]]]

I understand what this is but it doesn't look nice. (these x121101 etc. are my variables)

The result in Mathematica looks like this (other example):

Example result in Mathematica

It seems Mathematica has a build in method to produce pictures from results. Is there a way to produce the same picture in python?

The reason is with this picture it is easy to evaluate the structure of an equation and for complicated equations it is so time consuming to build equations by hand.

Ty and have a nice day.

Bla Bla
  • 33
  • 4
  • 1
    Since "make the result more beautiful" is your requirement try looking into using the Mathematica Export functions to export full .tex files which will allow you use any of the many available .tex file display and printing tools to see journal-quality published notation you have created. Google search for `.tex with python` finds info, but like many things it seems those tend to be about python being in control and squirting out .tex for someone else to have to deal with instead of python being able to accept .tex output from something else and display that beautifully. I hope it works for you – Bill Jun 09 '23 at 20:41
  • 1
    You might also try `InputForm[Rule[Globalx121101, Times[-1, Power[Plus[Times[-1, Power[Globalx121111, 2]], Times[-1, Power[Global\`x121121, 2]]], Rational[1, 2]]]]]` inside Mathematica which returns `Globalx121101 -> -Sqrt[-Globalx121111^2 - x121121^2]` instead of the more verbose internal version you showed above. But that may not be as beautiful as you desire. You can also look at `TraditionalForm[...]` in Mathematica and see whether you can use the output of that. That will use Mathematica to try to turn the result from MMA's structure into conventional math notation. – Bill Jun 09 '23 at 20:50
  • Ok I will look into it. ty But this is only a comment and I can't set that question answered check mark. – Bla Bla Jun 12 '23 at 13:34

0 Answers0