Skip to content

A fraction with "negative" numerator and "negative" denominator should be simplified #1773

@s-celles

Description

@s-celles

Hello,

Here is an other "trivial" case that I don't know how to manage with Symbolics.jl

julia> using Symbolics
julia> @variables V1, R1, C1, s
4-element Vector{Num}:
 V1
 R1
 C1
  s

julia> V2 = (-V1) / (-1 - R1*C1*s)
(-V1) / (-1 - C1*R1*s)

julia> expand(V2)
(-V1) / (-1 - C1*R1*s)

julia> simplify(V2)
(-V1) / (-1 - C1*R1*s)

I'm expecting V1 / (1 + R1*C1*s)

Any idea?

PS: it looks very odd in my electrical CAS solver (not yet published)

julia> circuit = parse_netlist("""
       Vin in 0 DC 1

       R1 in out 1k
       R2 out 0 2k

       .OP
       .PRINT DC V(out)

       .END""")
Circuit("netlist", NetworkElement[VoltageSource(:VIN, :in, Symbol("0"), VIN), Resistor(:R1, :in, :out, R1), Resistor(:R2, :out, Symbol("0"), R2)], Set([:in, :gnd, :out, Symbol("0")]), Probe[Probe("V_OUT", VOLTAGE, :OUT, nothing, nothing)], :gnd, Dict(:R2 => 2000.0, :VIN => 1.0, :R1 => 1000.0))

julia> results = solve(circuit, mode=COMPLETE)
CircuitResults(Circuit("netlist", NetworkElement[VoltageSource(:VIN, :in, Symbol("0"), VIN), Resistor(:R1, :in, :out, R1), Resistor(:R2, :out, Symbol("0"), R2)], Set([:in, :gnd, :out, Symbol("0")]), Probe[Probe("V_OUT", VOLTAGE, :OUT, nothing, nothing)], :gnd, Dict(:R2 => 2000.0, :VIN => 1.0, :R1 => 1000.0)), Dict{Symbol, Any}(:in => VIN, :gnd => 0, :out => (-R2*VIN) / (-R1 - R2), Symbol("0") => 0), Dict{Symbol, Any}(:R2 => (-VIN) / (-R1 - R2), :VIN => VIN / (-R1 - R2), :R1 => (-VIN) / (-R1 - R2)), COMPLETE)

julia> voltage(results, :out)
(-R2*VIN) / (-R1 - R2)

julia> current(results, :R2)
(-VIN) / (-R1 - R2)

julia> voltage(results, :out) * current(results, :R2)
(R2*(VIN^2)) / ((-R1 - R2)^2)

should be respectively:

  • VIN * R2 / (R1 + R2)
  • VIN / (R1 + R2)
  • (R2*(VIN^2)) / ((R1 + R2)^2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions